Skip to content

Commit

Permalink
dont gen the group_leave on admins node, user who was kicked out can …
Browse files Browse the repository at this point in the history
…leave
  • Loading branch information
Evanfeenstra committed Jul 7, 2020
1 parent d39bfc9 commit e0444fe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 63 deletions.
32 changes: 0 additions & 32 deletions api/controllers/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export async function kickChatMember(req, res){
chatId, contactId,
}})

const kickedContact = await models.Contact.findOne({where:{id:contactId}})

const owner = await models.Contact.findOne({ where: { isOwner: true } })
network.sendMessage({
chat: { ...chat.dataValues, contactIds:[contactId] }, // send only to the guy u kicked
Expand All @@ -43,36 +41,6 @@ export async function kickChatMember(req, res){
// delete all timers for this member
timers.removeTimersByContactIdChatId(contactId,chatId)

if(kickedContact){
// send group_leave to others
network.sendMessage({
chat: {...chat.dataValues, contactIds:newContactIds},
sender: {...owner.dataValues, alias:kickedContact.alias},
message: {},
type: constants.message_types.group_leave,
})
var date = new Date()
date.setMilliseconds(0)
const msg:{[k:string]:any} = {
chatId: chat.id,
type: constants.message_types.group_leave,
sender: (kickedContact.id) || 0,
messageContent:'', remoteMessageContent:'',
status: constants.statuses.confirmed,
date:date, createdAt:date, updatedAt:date,
senderAlias: kickedContact.alias
}
const message = await models.Message.create(msg)
socket.sendJson({
type: 'group_leave',
response: {
contact: jsonUtils.contactToJson(kickedContact),
chat: jsonUtils.chatToJson(chat),
message: jsonUtils.messageToJson(message, null)
}
})
}

success(res, jsonUtils.chatToJson(chat))
}

Expand Down
30 changes: 0 additions & 30 deletions dist/api/controllers/chats.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0444fe

Please sign in to comment.