diff --git a/app/lib/server/functions/notifications/index.js b/app/lib/server/functions/notifications/index.js index 8b247c8810a3..d76bb70eb486 100644 --- a/app/lib/server/functions/notifications/index.js +++ b/app/lib/server/functions/notifications/index.js @@ -11,15 +11,17 @@ import { settings } from '../../../../settings'; * @param {object} message the message to be parsed */ export function parseMessageTextPerUser(messageText, message, receiver) { - if (!message.msg && message.attachments && message.attachments[0]) { - const lng = receiver.language || settings.get('Language') || 'en'; + const lng = receiver.language || settings.get('Language') || 'en'; + + if (settings.get('Push_request_content_from_server')) { + return TAPi18n.__('You_have_a_new_message', { lng }); + } + if (!message.msg && message.attachments && message.attachments[0]) { return message.attachments[0].image_type ? TAPi18n.__('User_uploaded_image', { lng }) : TAPi18n.__('User_uploaded_file', { lng }); } if (message.msg && message.t === 'e2e') { - const lng = receiver.language || settings.get('Language') || 'en'; - return TAPi18n.__('Encrypted_message', { lng }); } diff --git a/app/push-notifications/server/lib/PushNotification.js b/app/push-notifications/server/lib/PushNotification.js index 5da6bbcc5314..dc97c7876e6b 100644 --- a/app/push-notifications/server/lib/PushNotification.js +++ b/app/push-notifications/server/lib/PushNotification.js @@ -16,27 +16,23 @@ export class PushNotification { } getNotificationConfig({ rid, uid: userId, mid: messageId, roomName, username, message, payload, badge = 1, category, idOnly = false }) { - let title; - if (roomName && roomName !== '') { - title = `${ roomName }`; - message = `${ username }: ${ message }`; - } else { - title = `${ username }`; - } + const title = idOnly ? '' : roomName || username; + + // message is being redacted already by 'parseMessageTextPerUser' if idOnly is true + const text = !idOnly && roomName !== '' ? `${ username }: ${ message }` : message; const config = { from: 'push', badge, sound: 'default', priority: 10, - title: idOnly ? '' : title, - text: idOnly ? ' ' : message, + title, + text, payload: { host: Meteor.absoluteUrl(), - ...idOnly || { rid }, messageId, notificationType: idOnly ? 'message-id-only' : 'message', - ...idOnly || payload, + ...idOnly || { rid, ...payload }, }, userId, notId: this.getNotificationId(rid), diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 3cdc681e9878..74b5eb672cac 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -3924,6 +3924,7 @@ "You_can_use_an_emoji_as_avatar": "You can also use an emoji as an avatar.", "You_can_use_webhooks_to_easily_integrate_livechat_with_your_CRM": "You can use webhooks to easily integrate Omnichannel with your CRM.", "You_cant_leave_a_livechat_room_Please_use_the_close_button": "You can't leave a omnichannel room. Please, use the close button.", + "You_have_a_new_message": "You have a new message", "You_have_been_muted": "You have been muted and cannot speak in this room", "You_have_n_codes_remaining": "You have __number__ codes remaining.", "You_have_not_verified_your_email": "You have not verified your email.", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index e24ac6175463..bdd58b9d87e3 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -3447,6 +3447,7 @@ "You_can_use_an_emoji_as_avatar": "Você também pode usar um emoji como um avatar.", "You_can_use_webhooks_to_easily_integrate_livechat_with_your_CRM": "Você pode usar webhooks para integrar facilmente o Omnichannel com seu CRM.", "You_cant_leave_a_livechat_room_Please_use_the_close_button": "Você não pode sair de uma sala de omnichannel. Por favor, use o botão de fechar sala.", + "You_have_a_new_message": "Nova mensagem", "You_have_been_muted": "Você foi silenciado e não pode falar nesta sala", "You_have_n_codes_remaining": "Você tem __number__ codes restantes.", "You_have_not_verified_your_email": "Você ainda não verificou o seu e-mail.",