1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 07:19:23 +00:00

Can get information about a single user membership

This commit is contained in:
Pierre HUBERT 2019-12-27 11:11:05 +01:00
parent 6fab4bf8e3
commit 675bf79c6e
2 changed files with 19 additions and 0 deletions

View File

@ -479,6 +479,23 @@ export class GroupsController {
h.success("The response to the request has been successfully saved!"); h.success("The response to the request has been successfully saved!");
} }
/**
* Get information about a single membership
*
* @param h Request handler
*/
public static async GetMembership(h: RequestHandler) {
const groupID = await h.postGroupIDWithAccess("groupID", GroupsAccessLevel.MODERATOR_ACCESS);
const userID = await h.postUserId("userID");
const membership = await GroupsHelper.GetMembershipInfo(groupID, userID);
if(membership == null)
h.error(404, "Specified user does not have any membership in this group!");
h.send(this.GroupMemberToAPI(membership));
}
/** /**
* Turn a GroupInfo object into a valid API object * Turn a GroupInfo object into a valid API object
* *

View File

@ -120,4 +120,6 @@ export const Routes : Route[] = [
{path: "/groups/update_membership_level", cb: (h) => GroupsController.UpdateMembership(h)}, {path: "/groups/update_membership_level", cb: (h) => GroupsController.UpdateMembership(h)},
{path: "/groups/respond_request", cb: (h) => GroupsController.RespondRequest(h)}, {path: "/groups/respond_request", cb: (h) => GroupsController.RespondRequest(h)},
{path: "/groups/get_membership", cb: (h) => GroupsController.GetMembership(h)},
] ]