Merge pull request #19612 from ramonlsouza/fix-tp-15
fix: poll results on chat export
This commit is contained in:
commit
de8fbf824b
@ -22,6 +22,7 @@ query getChatMessageHistory {
|
||||
message
|
||||
messageId
|
||||
messageType
|
||||
messageMetadata
|
||||
chatEmphasizedText
|
||||
createdAt
|
||||
user {
|
||||
|
@ -2,12 +2,17 @@ import { Message } from '/imports/ui/Types/message';
|
||||
import { stripTags, unescapeHtml } from '/imports/utils/string-utils';
|
||||
import { IntlShape, defineMessages } from 'react-intl';
|
||||
import { ChatMessageType } from '/imports/ui/core/enums/chat';
|
||||
import PollService from '/imports/ui/components/poll/service';
|
||||
|
||||
const intlMessages = defineMessages({
|
||||
chatClear: {
|
||||
id: 'app.chat.clearPublicChatMessage',
|
||||
description: 'message of when clear the public chat',
|
||||
},
|
||||
pollResult: {
|
||||
id: 'app.chat.pollResult',
|
||||
description: 'used in place of user name who published poll to chat',
|
||||
},
|
||||
});
|
||||
|
||||
export const htmlDecode = (input: string) => {
|
||||
@ -29,13 +34,22 @@ export const generateExportedMessages = (
|
||||
const hour = date.getHours().toString().padStart(2, '0');
|
||||
const min = date.getMinutes().toString().padStart(2, '0');
|
||||
const hourMin = `[${hour}:${min}]`;
|
||||
const userName = message.user ? `[${message.user.name} : ${message.user.role}]: ` : '';
|
||||
let userName = message.user ? `[${message.user.name} : ${message.user.role}]: ` : '';
|
||||
let messageText = '';
|
||||
|
||||
switch (message.messageType) {
|
||||
case ChatMessageType.CHAT_CLEAR:
|
||||
messageText = intl.formatMessage(intlMessages.chatClear);
|
||||
break;
|
||||
case ChatMessageType.POLL: {
|
||||
userName = `${intl.formatMessage(intlMessages.pollResult)}:\n`;
|
||||
|
||||
const metadata = JSON.parse(message.messageMetadata);
|
||||
const pollText = htmlDecode(PollService.getPollResultString(metadata, intl).split('<br/>').join('\n'));
|
||||
// remove last \n to avoid empty line
|
||||
messageText = pollText.slice(0, -1);
|
||||
break;
|
||||
}
|
||||
case ChatMessageType.TEXT:
|
||||
default:
|
||||
messageText = htmlDecode(message.message);
|
||||
|
Loading…
Reference in New Issue
Block a user