Skip to content

Commit

Permalink
fix: adding friends malfunction
Browse files Browse the repository at this point in the history
  • Loading branch information
mo9a7i committed Oct 12, 2023
1 parent 566858f commit 5996c12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ export async function addFriendByID(this:any, user_id: number): Promise<string |
const result = await this.getUser(userIdStr);
const newFriend = result?.data?.response?.user;

if (newFriend?.relationship === 'none') {
// seems like relationship field removed, proceed adding anyway
//if (newFriend?.relationship === 'none') {
if(true) {
const postUrl = `${this.basePath}users/${userIdStr}/request`;
const postResult = await axios.post(postUrl, querystring.stringify(this.config));
return postResult.data.response.user.relationship;
return postResult.data.response.user;
}

return false;
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ export default class SwarmappApi {
const friendships: any[] = [];

if (hereNow?.count > 0) {
console.log(`Adding ${hereNow.count} friends from ${checkin.venue.name}...`);
for (const group of hereNow.groups) {
console.log(`Adding ${group.count} friends from ${group.name}...`);
if (group.count > 0) {
console.log(`Adding ${group.items.length} friends from ${group.name}...`);
// if females only condition is set
const filteredItems = females_only ? group.items.filter((item: any) => item.user?.gender === 'female') : group.items;

Expand All @@ -206,6 +209,8 @@ export default class SwarmappApi {
);

friendships.push(...newFriendships);
console.log(`Added ${newFriendships.length} friends from ${group.name}...`);
console.log(newFriendships)
}
}
}
Expand Down

0 comments on commit 5996c12

Please sign in to comment.