1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-28 14:38:52 +00:00

Can change conversation name

This commit is contained in:
Pierre HUBERT 2019-11-30 14:25:06 +01:00
parent e3dec0ccaf
commit 47e9d46b4d
2 changed files with 34 additions and 1 deletions

View File

@ -90,7 +90,21 @@ export class ConversationsController {
);
}
// TODO : update moderation settings
// Change moderator settings
if(handler.hasPostParameter("members") || handler.hasPostParameter("name")) {
// Check if user is the moderator of the conversation
if(!await ConversationsHelper.IsUserModerator(handler.getUserId(), convID))
handler.error(401, "You are not allowed to perform changes on this conversation !");
// Update conversation name (if required)
if(handler.hasPostParameter("name")) {
const name = handler.postString("name");
await ConversationsHelper.SetName(convID, name == "false" ? "" : removeHTMLNodes(name));
}
}
handler.success("Conversation information successfully updated!");
}

View File

@ -146,6 +146,25 @@ export class ConversationsHelper {
}) == 1;
}
/**
* Change the name of a conversation
*
* @param convID Target conversation
* @param name New name for the conversation (empty name
* to remove it)
*/
public static async SetName(convID: number, name: string) {
await DatabaseHelper.UpdateRows({
table: LIST_TABLE,
where: {
id: convID
},
set: {
name: name
}
});
}
/**
* Update following state of the conversation
*