mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Can get a friendship status
This commit is contained in:
@ -60,6 +60,34 @@ export class FriendsController {
|
||||
h.send(this.FriendToAPI(info, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a friendship status
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async GetStatus(h: RequestHandler) {
|
||||
const friendID = await h.postUserId("friendID");
|
||||
|
||||
let response = {
|
||||
are_friend: false,
|
||||
sent_request: false,
|
||||
received_request: false,
|
||||
following: false
|
||||
}
|
||||
|
||||
response.are_friend = await FriendsHelper.AreFriend(h.getUserId(), friendID);
|
||||
|
||||
if(!response.are_friend) {
|
||||
response.sent_request = await FriendsHelper.SentRequest(h.getUserId(), friendID);
|
||||
response.received_request = await FriendsHelper.SentRequest(friendID, h.getUserId());
|
||||
}
|
||||
else
|
||||
response.following = await FriendsHelper.IsFollowing(h.getUserId(), friendID);
|
||||
|
||||
|
||||
h.send(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a friend object into an API entry
|
||||
*
|
||||
|
@ -81,6 +81,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/friends/get_single_infos", cb: (h) => FriendsController.GetSingleFrienshipInfo(h)},
|
||||
|
||||
{path: "/friends/getStatus", cb: (h) => FriendsController.GetStatus(h)},
|
||||
|
||||
|
||||
// Conversations controller
|
||||
{path: "/conversations/create", cb: (h) => ConversationsController.CreateConversation(h)},
|
||||
|
Reference in New Issue
Block a user