diff --git a/bigbluebutton-html5/imports/api/chat/server/handlers/chatPublicHistoryClear.js b/bigbluebutton-html5/imports/api/chat/server/handlers/chatPublicHistoryClear.js index 47d861bac4ec979cb0ed8d614ed756842f956826..3f29aab4c1931619204c3d2b3015fbc0c6ff06b6 100644 --- a/bigbluebutton-html5/imports/api/chat/server/handlers/chatPublicHistoryClear.js +++ b/bigbluebutton-html5/imports/api/chat/server/handlers/chatPublicHistoryClear.js @@ -10,19 +10,20 @@ export default function publicHistoryClear({ header }, meetingId) { const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system; if (meetingId) { - Chat.remove({ meetingId, toUserId: PUBLIC_CHAT_USERID }, - Logger.info(`Cleared Chats (${meetingId})`)); + Chat.remove( + { meetingId, toUserId: PUBLIC_CHAT_USERID }, + Logger.info(`Cleared Chats (${meetingId})`), + ); addChat(meetingId, { - message: '<b><i>The public chat history was cleared by a moderator</i></b>', + message: CHAT_CONFIG.system_messages_keys.chat_clear, fromTime: new Date().getTime(), toUserId: PUBLIC_CHAT_USERID, toUsername: PUBLIC_CHAT_USERNAME, fromUserId: SYSTEM_CHAT_TYPE, fromUsername: '', fromColor: '', - }, - ); + }); } return null; diff --git a/bigbluebutton-html5/imports/ui/components/chat/container.jsx b/bigbluebutton-html5/imports/ui/components/chat/container.jsx index fcfd36f6fcbac8b9f42cc0bff9dbfbd04da1c397..088af86a6cdb495cde3446ad9cea55315b20b3b2 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/chat/container.jsx @@ -6,9 +6,13 @@ import ChatService from './service'; const CHAT_CONFIG = Meteor.settings.public.chat; const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id; - +const CHAT_CLEAR = CHAT_CONFIG.system_messages_keys.chat_clear; const intlMessages = defineMessages({ + [CHAT_CLEAR]: { + id: 'app.chat.clearPublicChatMessage', + description: 'message of when clear the public chat', + }, titlePublic: { id: 'app.chat.titlePublic', description: 'Public chat title', @@ -37,46 +41,52 @@ export default injectIntl(createContainer(({ params, intl }) => { let isChatLocked = ChatService.isChatLocked(chatID); let title = intl.formatMessage(intlMessages.titlePublic); let chatName = title; + let partnerIsLoggedOut = false; + let systemMessageIntl = {}; if (chatID === PUBLIC_CHAT_KEY) { messages = ChatService.reduceAndMapMessages((ChatService.getPublicMessages())); } else { messages = ChatService.getPrivateMessages(chatID); - } - - const user = ChatService.getUser(chatID, '{{NAME}}'); - - let partnerIsLoggedOut = false; - - if (user) { + const user = ChatService.getUser(chatID); + chatName = user.name; + systemMessageIntl = { 0: user.name }; + title = intl.formatMessage(intlMessages.titlePrivate, systemMessageIntl); partnerIsLoggedOut = !user.isOnline; - if (messages && chatID !== PUBLIC_CHAT_KEY) { - const chatUser = ChatService.getUser(chatID, '{{NAME}}'); - - title = intl.formatMessage(intlMessages.titlePrivate, { 0: chatUser.name }); - chatName = chatUser.name; - - if (!chatUser.isOnline) { - const time = Date.now(); - const id = `partner-disconnected-${time}`; - const messagePartnerLoggedOut = { + if (partnerIsLoggedOut) { + const time = Date.now(); + const id = `partner-disconnected-${time}`; + const messagePartnerLoggedOut = { + id, + content: [{ id, - content: [{ - id, - text: intl.formatMessage(intlMessages.partnerDisconnected, { 0: chatUser.name }), - time, - }], + text: 'partnerDisconnected', time, - sender: null, - }; + }], + time, + sender: null, + }; - messages.push(messagePartnerLoggedOut); - isChatLocked = true; - } + messages.push(messagePartnerLoggedOut); + isChatLocked = true; } } + messages = messages.map((message) => { + if (message.sender) return message; + + return { + ...message, + content: message.content.map(content => ({ + ...content, + text: content.text in intlMessages ? + `<b><i>${intl.formatMessage(intlMessages[content.text], systemMessageIntl)}</i></b>` : content.text, + })), + }; + }); + + const scrollPosition = ChatService.getScrollPosition(chatID); const hasUnreadMessages = ChatService.hasUnreadMessages(chatID); const lastReadMessageTime = ChatService.lastReadMessageTime(chatID); diff --git a/bigbluebutton-html5/private/config/public/chat.yaml b/bigbluebutton-html5/private/config/public/chat.yaml index 8b291511391c9e37a0499b45078feb8006f88c53..81bc370d11c44b28707c34f2b75b30e6438a1437 100644 --- a/bigbluebutton-html5/private/config/public/chat.yaml +++ b/bigbluebutton-html5/private/config/public/chat.yaml @@ -17,3 +17,5 @@ chat: storage_key: 'UNREAD_CHATS' # Chat paths path_route: 'users/chat/' + system_messages_keys: + chat_clear: 'PUBLIC_CHAT_CLEAR' diff --git a/bigbluebutton-html5/private/locales/en.json b/bigbluebutton-html5/private/locales/en.json index ae6d0e7fd3dd0a06f6a35e1c6d8ab472eeb65100..da0db9ce2a17e369c09af49c13be26f9fddaeec7 100644 --- a/bigbluebutton-html5/private/locales/en.json +++ b/bigbluebutton-html5/private/locales/en.json @@ -17,6 +17,7 @@ "app.chat.dropdown.save": "Save", "app.chat.label": "Chat", "app.chat.emptyLogLabel": "Chat log empty", + "app.chat.clearPublicChatMessage": "The public chat history was cleared by a moderator", "app.userList.usersTitle": "Users", "app.userList.participantsTitle": "Participants", "app.userList.messagesTitle": "Messages",