diff options
author | megos <gmegos.27@gmail.com> | 2017-06-28 21:37:51 +0900 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-06-28 13:37:51 +0100 |
commit | 58b32319160f9f15865db6426bb6b4e72415a064 (patch) | |
tree | a2115c2c6803969b3d38d69d4d501d879a425661 /webapp | |
parent | c66799a83943af0ae03b17b657936e5327c55550 (diff) | |
download | chat-58b32319160f9f15865db6426bb6b4e72415a064.tar.gz chat-58b32319160f9f15865db6426bb6b4e72415a064.tar.bz2 chat-58b32319160f9f15865db6426bb6b4e72415a064.zip |
add attachments notification (#6769)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/actions/notification_actions.jsx | 18 | ||||
-rwxr-xr-x | webapp/i18n/en.json | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/webapp/actions/notification_actions.jsx b/webapp/actions/notification_actions.jsx index 82a68c452..c07dc0d56 100644 --- a/webapp/actions/notification_actions.jsx +++ b/webapp/actions/notification_actions.jsx @@ -73,7 +73,21 @@ export function sendDesktopNotification(post, msgProps) { } } - let notifyText = post.message.replace(/\n+/g, ' '); + let notifyText = post.message; + + const msgPropsPost = JSON.parse(msgProps.post); + const attachments = msgPropsPost && msgPropsPost.props && msgPropsPost.props.attachments ? msgPropsPost.props.attachments : []; + let image = false; + attachments.forEach((attachment) => { + if (notifyText.length === 0) { + notifyText = attachment.fallback || + attachment.pretext || + attachment.text; + } + image |= attachment.image_url.length > 0; + }); + + notifyText.replace(/\n+/g, ' '); if (notifyText.length > 50) { notifyText = notifyText.substring(0, 49) + '...'; } @@ -84,6 +98,8 @@ export function sendDesktopNotification(post, msgProps) { body = username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'); } else if (msgProps.otherFile) { body = username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'); + } else if (image) { + body = username + Utils.localizeMessage('channel_loader.postedImage', ' posted an image'); } else { body = username + Utils.localizeMessage('channel_loader.something', ' did something new'); } diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index 038bb09cb..419486b9d 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1127,6 +1127,7 @@ "channel_loader.unknown_error": "We received an unexpected status code from the server.", "channel_loader.uploadedFile": " uploaded a file", "channel_loader.uploadedImage": " uploaded an image", + "channel_loader.postedImage": " posted an image", "channel_loader.wrote": " wrote: ", "channel_members_dropdown.channel_admin": "Channel Admin", "channel_members_dropdown.channel_member": "Channel Member", |