Skip to content

Commit

Permalink
Merge branch 'master' into rocket-packages
Browse files Browse the repository at this point in the history
* master:
  Respond a transparent pixel if avatar doesn't exists. Fixes #149
  Sort usernames in room closes #151
  Remove unused code
  rename config file
  • Loading branch information
engelgabriel committed Jun 5, 2015
2 parents 47b6512 + 093fcb9 commit e2bf20d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 44 deletions.
Binary file added public/images/transparent-pixel.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions server/methods/addUserToRoom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ Meteor.methods
return

update =
$addToSet:
usernames: data.username
$push:
usernames:
$each: [data.username]
$sort: 1

newUser = Meteor.users.findOne username: data.username

Expand Down
38 changes: 0 additions & 38 deletions server/methods/forwardRoom.coffee

This file was deleted.

5 changes: 4 additions & 1 deletion server/methods/sendMessage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ Meteor.methods
roomUpdate = { $set: { lm: now }, $inc: { msgs: 1 } }

if Meteor.userId() and not Meteor.user().username in roomData.usernames
roomUpdate.$push = { usernames: Meteor.user().username }
roomUpdate.$push =
usernames:
$each: [ Meteor.user().username ]
$sort: 1

ChatRoom.update rid, roomUpdate

Expand Down
6 changes: 4 additions & 2 deletions server/methods/setUsername.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Meteor.methods
if not user.username?
# put user in general channel
ChatRoom.update '57om6EQCcFami9wuT',
$addToSet:
usernames: username
$push:
usernames:
$each: [username]
$sort: 1

if not ChatSubscription.findOne(rid: '57om6EQCcFami9wuT', 'u._id': user._id)?
ChatSubscription.insert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ Meteor.startup ->
this.params.username
file = RocketChatFileAvatarInstance.getFileWithReadStream this.params.username

this.setContentType 'image/jpeg'
this.addHeader 'Content-Disposition', 'inline'

if not file?
this.setContentType 'image/gif'
ws = this.createWriteStream()
Meteor.defer ->
ws.write 'R0lGODlhAQABAIAAAP///////yH5BAEHAAEALAAAAAABAAEAAAICTAEAOw==', 'base64'
ws.end()
return

this.setContentType 'image/jpeg'
this.addHeader 'Content-Length', file.length

file.readStream.pipe this.createWriteStream()
Expand Down

0 comments on commit e2bf20d

Please sign in to comment.