mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 16:45:17 +00:00
Can invite a user to join a group.
This commit is contained in:
@ -359,6 +359,36 @@ class GroupsController {
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite a user to join the network
|
||||
*
|
||||
* @url POST /groups/invite
|
||||
*/
|
||||
public function inviteUser(){
|
||||
|
||||
user_login_required();
|
||||
|
||||
//Get target group ID
|
||||
$groupID = getPostGroupIdWithAccess("group_id", GroupInfo::MODERATOR_ACCESS);
|
||||
|
||||
//Get target user ID
|
||||
$userID = getPostUserID("userID");
|
||||
|
||||
//Get the current status of the user over the group
|
||||
if(components()->groups->getMembershipLevel($userID, $groupID) != GroupMember::VISITOR)
|
||||
Rest_fatal_error(401, "The user is not a visitor for this group!");
|
||||
|
||||
//Save the invitation of the user
|
||||
if(!components()->groups->sendInvitation($userID, $groupID))
|
||||
Rest_fatal_error(500, "Could not send user invitation!");
|
||||
|
||||
//Create notification
|
||||
create_group_membership_notification($userID, userID, $groupID, Notification::SENT_GROUP_MEMBERSHIP_INVITATION);
|
||||
|
||||
//Success
|
||||
return array("success" => "The user has been successfully invited to join this group!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to a membership invitation
|
||||
*
|
||||
|
Reference in New Issue
Block a user