Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Warn users when a new one joins

  • Loading branch information...
commit 069cf6f4fd7b579c9a728b0774b67aba57fcae37 1 parent e7c4704
Rodrigo Navarro authored

Showing 2 changed files with 10 additions and 3 deletions. Show diff stats Hide diff stats

  1. +9 2 app.js
  2. +1 1  views/partials/message.jade
11 app.js
@@ -149,8 +149,15 @@ app.get('/rooms/:room_id', filters.getRoom, filters.getUser, function(req, res){
149 149 });
150 150
151 151 app.get('/rooms/:room_id/join', filters.getRoom, function(req, res){
152   - if (!req.room.users[req.sessionID])
153   - req.room.users[req.sessionID] = new User(req.query.user.nick);
  152 + if (!req.room.users[req.sessionID]) {
  153 + var user = new User(req.query.user.nick);
  154 + req.room.users[req.sessionID] = user;
  155 +
  156 + // Alert people that a new user joined the room
  157 + var message = new Message(req.room.name, user.nick + ' joined!');
  158 + message.type = 'notice';
  159 + req.room.appendMessage(message);
  160 + }
154 161
155 162 res.redirect('/rooms/' + req.room.id);
156 163 });
2  views/partials/message.jade
... ... @@ -1,4 +1,4 @@
1   -tr.message(data-time: message.sent_at)
  1 +tr.message(data-time: message.sent_at, class: message.type)
2 2 td!= message.from
3 3 td!= new Date(message.sent_at)
4 4 td!= message.text

0 comments on commit 069cf6f

Please sign in to comment.
Something went wrong with that request. Please try again.