Skip to content

Commit

Permalink
Less strict requirements for notification
Browse files Browse the repository at this point in the history
  • Loading branch information
janbaykara committed Apr 30, 2015
1 parent 828f61e commit c97d646
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/background.messenger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ app.messenger = {
initiateNotification: function(res) {
var message = res.data.messages[0]
if (
message.message_type === 'chat' &&
(message.direct_message || message.privacy === "private" || message.message_type === 'chat') &&
(message.sender_id !== app.session.yammer_uid || app.config.debug) &&
(message.id !== app.session.lastMsgId)
) {
app.session.set("lastMsgId",message.id)
app.messenger.buildNotification(res)

if(typeof app.session.yammer_uid === 'undefined')
app.session.set("yammer_uid",res.data.meta.current_user_id)

app.messenger.buildNotification(res)

} else if(app.config.debug) { // Error messages
if (message.id === app.session.lastMsgId)
console.warn("Already notified for "+message.id+" --- Too late: "+res.detector)
Expand All @@ -28,19 +30,23 @@ app.messenger = {
// Prepare the message notification content
buildNotification: function(res) {
res.message = res.data.messages[0]
var imgSize = 180

// User
var sender = {
type: res.message.sender_type,
id: res.message.sender_id
}
res.message.person = _.where(res.data.references, sender)[0]
// Image
var imgSize = 180
res.message.person.mugshot_url_template = res.message.person.mugshot_url_template.replace("{height}", imgSize)
res.message.person.mugshot_url_template = res.message.person.mugshot_url_template.replace("{width}", imgSize)
res.message.person.img_url = res.message.person.mugshot_url_template
// Date
res.message.unix_time = Date.parse(res.message.created_at)
res.message.date_object = new Date(res.message.unix_time)
res.message.notification_id = _.uniqueId()

res.message.notification_id = "boom-yammer-osx-" + _.uniqueId()
if(typeof app.session.lastMsgId !== 'undefined')
app.messenger.sendNotification(res)
},
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Yammer Desktop Notifier",
"short_name": "Yammer Notifier",
"description": "Yammer Desktop Notifier provides desktop notifications when you receive new private Yammer chat messages.",
"version": "1.1.3",
"version": "1.1.4",
"author": "Jan Baykara <jan@baykara.co.uk>",
"homepage_url": "https://github.com/janbaykara/Chrome-YammerMessageNotifications",
"icons": { "128": "img/icon128.png" },
Expand Down

0 comments on commit c97d646

Please sign in to comment.