Change to fetch from chat system id, issue #3792 HTML5
This commit is contained in:
parent
6727f14ab7
commit
b432ffd68b
@ -0,0 +1,26 @@
|
|||||||
|
import Chat from '/imports/api/chat';
|
||||||
|
import Logger from '/imports/startup/server/logger';
|
||||||
|
import { check } from 'meteor/check';
|
||||||
|
import { BREAK_LINE } from '/imports/utils/lineEndings.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove any system message from the user with userId.
|
||||||
|
*
|
||||||
|
* @param {string} meetingId
|
||||||
|
* @param {string} userId
|
||||||
|
*/
|
||||||
|
export default function clearUserSystemMessages(meetingId, userId) {
|
||||||
|
|
||||||
|
check(meetingId, String);
|
||||||
|
check(userId, String);
|
||||||
|
|
||||||
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
||||||
|
|
||||||
|
const selector = {
|
||||||
|
meetingId,
|
||||||
|
"message.from_userid": CHAT_CONFIG.type_system,
|
||||||
|
"message.to_userid": userId,
|
||||||
|
}
|
||||||
|
|
||||||
|
return Chat.remove(selector, Logger.info(`Removing system messages from: (${userId})`));
|
||||||
|
};
|
@ -1,20 +0,0 @@
|
|||||||
import Chat from '/imports/api/chat';
|
|
||||||
import Logger from '/imports/startup/server/logger';
|
|
||||||
import { check } from 'meteor/check';
|
|
||||||
import { BREAK_LINE } from '/imports/utils/lineEndings.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove from chat a message that match the regex 'message' param.
|
|
||||||
*
|
|
||||||
* @param {string} meetingId
|
|
||||||
* @param {string} userId
|
|
||||||
* @param {string} message
|
|
||||||
*/
|
|
||||||
export default function removeChat(meetingId, userId, message) {
|
|
||||||
if (meetingId && userId && message) {
|
|
||||||
const modifiers = { meetingId: meetingId, "message.to_userid": userId ,"message.message":{ '$regex': message, '$options': 'i' }};
|
|
||||||
|
|
||||||
return Chat.remove(modifiers
|
|
||||||
, Logger.info(`Removing messages that match: (${message}) `));
|
|
||||||
}
|
|
||||||
};
|
|
@ -4,7 +4,7 @@ import Meetings from '/imports/api/meetings';
|
|||||||
import Users from '/imports/api/users';
|
import Users from '/imports/api/users';
|
||||||
|
|
||||||
import addChat from '/imports/api/chat/server/modifiers/addChat';
|
import addChat from '/imports/api/chat/server/modifiers/addChat';
|
||||||
import removeChat from '/imports/api/chat/server/modifiers/removeChat';
|
import clearUserSystemMessages from '/imports/api/chat/server/modifiers/clearUserSystemMessages';
|
||||||
|
|
||||||
export default function handleValidateAuthToken({ payload }) {
|
export default function handleValidateAuthToken({ payload }) {
|
||||||
const meetingId = payload.meeting_id;
|
const meetingId = payload.meeting_id;
|
||||||
@ -41,7 +41,7 @@ export default function handleValidateAuthToken({ payload }) {
|
|||||||
|
|
||||||
if (numChanged) {
|
if (numChanged) {
|
||||||
if (validStatus) {
|
if (validStatus) {
|
||||||
clearPastWelcomeMessage(meetingId, userId);
|
clearUserSystemMessages(meetingId, userId);
|
||||||
addWelcomeChatMessage(meetingId, userId);
|
addWelcomeChatMessage(meetingId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,17 +52,6 @@ export default function handleValidateAuthToken({ payload }) {
|
|||||||
return Users.update(selector, modifier, cb);
|
return Users.update(selector, modifier, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Prevent the chat message having multiple welcome message showing to user, removing the past ones.
|
|
||||||
* @param {string} meetingId
|
|
||||||
* @param {string} userId
|
|
||||||
*/
|
|
||||||
const clearPastWelcomeMessage = (meetingId, userId) => {
|
|
||||||
const APP_CONFIG = Meteor.settings.public.app;
|
|
||||||
|
|
||||||
return removeChat(meetingId, userId,APP_CONFIG.defaultWelcomeMessageFooter);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addWelcomeChatMessage = (meetingId, userId) => {
|
const addWelcomeChatMessage = (meetingId, userId) => {
|
||||||
const APP_CONFIG = Meteor.settings.public.app;
|
const APP_CONFIG = Meteor.settings.public.app;
|
||||||
const CHAT_CONFIG = Meteor.settings.public.chat;
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
||||||
|
Loading…
Reference in New Issue
Block a user