1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-24 22:39:21 +00:00

Can update "can_everyone_add_members" conversation setting

This commit is contained in:
Pierre HUBERT 2020-04-25 18:34:31 +02:00
parent 7aa258627f
commit 5d604bc576
2 changed files with 29 additions and 1 deletions

View File

@ -95,7 +95,7 @@ export class ConversationsController {
}
// Change moderator settings
if(h.hasPostParameter("members") || h.hasPostParameter("name")) {
if(h.hasPostParameter("members") || h.hasPostParameter("name") || h.hasPostParameter("canEveryoneAddMembers")) {
// Check if user is the moderator of the conversation
if(!await ConversationsHelper.IsUserModerator(h.getUserId(), convID))
@ -119,6 +119,11 @@ export class ConversationsController {
await ConversationsHelper.SetMembers(convID, members);
}
// Update "canEveryoneAddMembers" parameter
if(h.hasPostParameter("canEveryoneAddMembers")) {
await ConversationsHelper.SetCanEveryoneAddMembers(convID, h.postBool("canEveryoneAddMembers"));
}
}
h.success("Conversation information successfully updated!");
@ -160,6 +165,8 @@ export class ConversationsController {
* Refresh current user conversations
*
* @param h Request handler
* @deprecated Only ComunicWeb was using this method until
* the introduction of WebSockets...
*/
public static async RefreshList(h: RequestHandler) {

View File

@ -208,6 +208,27 @@ export class ConversationsHelper {
}
}
/**
* Specify whether any member of this conversation can invite other users
* to join it
*
* @param convID Target conversation ID
* @param allow If set to true, all the members of the conversation
* will be allowed to add members to this conversation (this parameters
* is not related with the deletion of members)
*/
public static async SetCanEveryoneAddMembers(convID: number, allow: boolean) {
await DatabaseHelper.UpdateRows({
table: LIST_TABLE,
where: {
"id": convID
},
set: {
"can_everyone_add_members": allow ? 1 : 0
}
})
}
/**
* Update following state of the conversation
*