Skip to content

Commit

Permalink
Create a user rocket.cat and set avatar on system initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Dec 10, 2015
1 parent c3cfb05 commit e9aa665
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Binary file added private/avatars/rocketcat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions server/startup/initialData.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ Meteor.startup ->
RocketChat.models.Rooms.createWithIdTypeAndName 'GENERAL', 'c', 'general',
default: true

if not RocketChat.models.Users.findOneByUsername('rocket.cat')?
userId = RocketChat.models.Users.create
name: "Rocket.Cat"
username: 'rocket.cat'
status: "offline"
statusDefault: "offline"
utcOffset: 0
active: true
bot: true

rs = RocketChatFile.bufferToStream new Buffer(Assets.getBinary('avatars/rocketcat.png'), 'utf8')
RocketChatFileAvatarInstance.deleteFile "rocket.cat.jpg"
ws = RocketChatFileAvatarInstance.createWriteStream "rocket.cat.jpg", 'image/png'
ws.on 'end', Meteor.bindEnvironment ->
RocketChat.models.Users.setAvatarOrigin userId, 'local'

rs.pipe(ws)


if process.env.ADMIN_EMAIL? and process.env.ADMIN_PASS?
re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if re.test process.env.ADMIN_EMAIL
Expand Down

0 comments on commit e9aa665

Please sign in to comment.