The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/livechat/server/hooks/markRoomResponded.js

29 lines
711 B

import { callbacks } from '../../../callbacks';
import { Rooms } from '../../../models';
callbacks.add('afterSaveMessage', function(message, room) {
// skips this callback if the message was edited
if (!message || message.editedAt) {
return message;
}
// check if room is yet awaiting for response
if (!(typeof room.t !== 'undefined' && room.t === 'l' && room.waitingResponse)) {
return message;
}
// if the message has a token, it was sent by the visitor, so ignore it
if (message.token) {
return message;
}
Rooms.setResponseByRoomId(room._id, {
user: {
_id: message.u._id,
username: message.u.username,
},
});
return message;
}, callbacks.priority.LOW, 'markRoomResponded');