1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Can respond to a friendship request

This commit is contained in:
2020-01-01 12:07:26 +01:00
parent d8bc8022c0
commit eefba81fd3
3 changed files with 51 additions and 0 deletions

View File

@ -130,6 +130,36 @@ export class FriendsHelper {
}
);
}
/**
* Respond to a friendship request
*
* @param userID The ID of the user who respond to the request
* @param friendID The ID of the user who sent the request
* @param accept TRUE to accept / FALSE else
*/
public static async RespondRequest(userID: number, friendID: number, accept: boolean) : Promise<boolean> {
// Delete the request
await this.RemoveRequest(friendID, userID);
// If the request was rejected
if(!accept)
return;
// If the request was accepted
await DatabaseHelper.InsertRow(FRIENDS_TABLE, {
ID_personne: userID,
ID_amis: friendID,
actif: 1
});
await DatabaseHelper.InsertRow(FRIENDS_TABLE, {
ID_personne: friendID,
ID_amis: userID,
actif: 1
});
}
/**
* Count the number of friendship requests a user