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

Can respond to membership invitation

This commit is contained in:
2019-12-26 18:16:44 +01:00
parent 33b01207d3
commit 5bb65e70bb
3 changed files with 87 additions and 0 deletions

View File

@ -308,6 +308,27 @@ export class GroupsController {
h.success("The user has been successfully invited to join the group!");
}
/**
* Respond to a user invitation
*
* @param h Request handler
*/
public static async RespondInvitation(h: RequestHandler) {
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
const accept = h.postBool("accept");
// Check if the user really received an invitation to join the group
if(!await GroupsHelper.ReceivedInvitation(groupID, h.getUserId()))
h.error(404, "Invitation not found!");
// Respond to the invitation
await GroupsHelper.RespondInvitation(groupID, h.getUserId(), accept);
// TODO : Create a notification
h.success("Response to the invitation was successfully saved!");
}
/**
* Turn a GroupInfo object into a valid API object
*

View File

@ -108,4 +108,6 @@ export const Routes : Route[] = [
{path: "/groups/get_members", cb: (h) => GroupsController.GetMembers(h)},
{path: "/groups/invite", cb: (h) => GroupsController.InviteUser(h)},
{path: "/groups/respond_invitation", cb: (h) => GroupsController.RespondInvitation(h)},
]