diff --git a/bigbluebutton-html5/imports/api/chat/server/methods/sendChat.js b/bigbluebutton-html5/imports/api/chat/server/methods/sendChat.js
index a53f5743f8..5d56026ad6 100755
--- a/bigbluebutton-html5/imports/api/chat/server/methods/sendChat.js
+++ b/bigbluebutton-html5/imports/api/chat/server/methods/sendChat.js
@@ -54,7 +54,7 @@ export default function sendChat(credentials, message) {
}
if (!isAllowedTo(actionName, credentials)
- && message.from_userid !== requesterUserId) {
+ && message.from_userid !== requesterUserId) {
throw new Meteor.Error('not-allowed', `You are not allowed to sendChat`);
}
diff --git a/bigbluebutton-html5/imports/api/chat/server/modifiers/clearUserSystemMessages.js b/bigbluebutton-html5/imports/api/chat/server/modifiers/clearUserSystemMessages.js
new file mode 100755
index 0000000000..28360789ac
--- /dev/null
+++ b/bigbluebutton-html5/imports/api/chat/server/modifiers/clearUserSystemMessages.js
@@ -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})`));
+};
diff --git a/bigbluebutton-html5/imports/api/chat/server/modifiers/removeChat.js b/bigbluebutton-html5/imports/api/chat/server/modifiers/removeChat.js
deleted file mode 100755
index 4e0ccad675..0000000000
--- a/bigbluebutton-html5/imports/api/chat/server/modifiers/removeChat.js
+++ /dev/null
@@ -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}) `));
- }
-};
diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js
index fb65f516d1..b1fdda6ace 100644
--- a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js
+++ b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js
@@ -4,7 +4,7 @@ import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
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 }) {
const meetingId = payload.meeting_id;
@@ -41,7 +41,7 @@ export default function handleValidateAuthToken({ payload }) {
if (numChanged) {
if (validStatus) {
- clearPastWelcomeMessage(meetingId, userId);
+ clearUserSystemMessages(meetingId, userId);
addWelcomeChatMessage(meetingId, userId);
}
@@ -52,17 +52,6 @@ export default function handleValidateAuthToken({ payload }) {
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 APP_CONFIG = Meteor.settings.public.app;
const CHAT_CONFIG = Meteor.settings.public.chat;