Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e147daf7 authored by lior's avatar lior
Browse files

add leaver message and call to execute quitgroup

parent 7754bce1
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
const databaseManager = require("./mongoose");
const commandHelper = require("./commandHelper");
const postHandler = require('./postToService');
/**
*
......@@ -524,6 +525,8 @@ async function ExecuteQuitGroup(data, targetGroupID, userMediaID)
await databaseManager.changeMemberGroupTargetByUserID(userData._id, "");
}
})
data.text = "Successfully quit group " + targetGroup.groupName + ".";
await postHandler.postToPlatform(data);
const userNickname = await databaseManager.findUserNicknameByUserIDInGroup(targetGroup, userDatabase._id);
data.text = userNickname + " has left the group " + targetGroup.groupName + ".";
data.targetGroup = targetGroupID;
......@@ -560,23 +563,7 @@ async function VerifyAndExecuteQuitGroup(data, userMediaID)
data.text = "Cannot quit a group while a session is opened. Please type !quitSession to return to the session to the group, then type !quitSession to quit the session to the group."
return data;
}
return await commandHelper.executeCommandOnGroup(serverData.text,async function(targetGroup){
//verify and remove each member that could be in a private session with the user in the group.
const connectedUsers = await databaseManager.findConnectedMembersByGroupID(targetGroup._id);
connectedUsers.forEach(user => async function(){
const userData = await databaseManager.findUserByUserID(user._id);
if(userData.userTarget === userDatabase._id.toString())
{
await databaseManager.changeUserStateByID(userData._id, "sendingToGroup");
await databaseManager.changeMemberGroupTargetByUserID(userData._id, "");
}
})
const userNickname = await findUserNicknameByUserIDInGroup(targetGroup, userDatabase._id);
data.text = userNickname + " has left the group " + targetGroup.groupName + ".";
return data;
},
return await commandHelper.executeCommandOnGroup(data.message, ExecuteQuitGroup,
{
"type":"talkToGroup",
"command":"QT",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment