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:
@ -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
|
||||
*
|
||||
|
@ -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)},
|
||||
]
|
Reference in New Issue
Block a user