Skip to content

Commit

Permalink
Add notification for tipping.
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Jun 26, 2015
1 parent 2cfb842 commit 64b4170
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
22 changes: 21 additions & 1 deletion soundtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,27 @@ app.post('/tips', requireLogin , function(req, res, next) {
context_uid: Math.random(),
context_url: 'https://soundtrack.io'
}, function(err, results) {
return res.send(err || results);
var result = err || results;

res.send(result);

if (result.errors) return;

res.render('partials/announcement', {
message: {
message: req.user.username + ' tipped ' + room.track.curator.username + ' for this track!',
created: new Date(),
track: room.track
}
}, function(err, html) {
room.broadcast({
type: 'announcement',
data: {
formatted: html,
created: new Date()
}
});
});
});
} else {
return res.send({ errors: room.track.curator.username + ' hasn\'t linked their ChangeTip account. :(' });
Expand Down
7 changes: 5 additions & 2 deletions views/partials/announcement.jade
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.message
abbr.timestamp.pull-right(title="#{moment(message.created).format()}") #{moment(message.created).format('HH:mm:ss')}
strong#announcement !{message.message}
if (message._track && message._track._id)
abbr.timestamp.pull-right(title="#{moment(message.created).format()}\n\"#{message._track.title}\" by #{message._track._artist.name} was playing.", datetime="#{moment(message.created).format()}") #{moment(message.created).format('HH:mm:ss')}
else
abbr.timestamp.pull-right(title="#{moment(message.created).format()}") #{moment(message.created).format('HH:mm:ss')}
strong#announcement !{message.message}
3 changes: 1 addition & 2 deletions views/people.jade
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ block content
if (person.profiles && person.profiles.changetip && person.profiles.changetip.id)
|
a(href="https://www.changetip.com/tipme/#{person.profiles.changetip.username}")
img(style="max-height: 32px;", src="/img/changetip.png", title="#{person.profiles.changetip.username}")

img(style="max-height: 16px;", src="/img/changetip.png", title="#{person.profiles.changetip.username}")
2 changes: 1 addition & 1 deletion views/person.jade
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ block content
img(src="/img/spotify.png", title="#{person.profiles.spotify.username}")
if (person.profiles.changetip && person.profiles.changetip.id)
a(href="https://www.changetip.com/tipme/#{person.profiles.changetip.username}")
img(style="max-height: 32px;", src="/img/changetip.png", title="#{person.profiles.changetip.username}")
img(style="max-height: 16px;", src="/img/changetip.png", title="#{person.profiles.changetip.username}")

if (artist)
span.badge artist
Expand Down

0 comments on commit 64b4170

Please sign in to comment.