Skip to content

Commit

Permalink
v1.0.3 - Fixed issue with IP view
Browse files Browse the repository at this point in the history
  • Loading branch information
igorantun committed Aug 10, 2015
1 parent d0dadea commit 9a55593
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Node.JS Chat
============
[![GitHub Stars](https://img.shields.io/github/stars/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/stargazers) [![GitHub Issues](https://img.shields.io/github/issues/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/issues) [![Current Version](https://img.shields.io/badge/version-1.0.0-green.svg)](https://github.com/IgorAntun/node-chat) [![Live Demo](https://img.shields.io/badge/demo-online-green.svg)](https://igorantun.com/chat) " [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/IgorAntun/node-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![GitHub Stars](https://img.shields.io/github/stars/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/stargazers) [![GitHub Issues](https://img.shields.io/github/issues/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/issues) [![Current Version](https://img.shields.io/badge/version-1.0.3-green.svg)](https://github.com/IgorAntun/node-chat) [![Live Demo](https://img.shields.io/badge/demo-online-green.svg)](https://igorantun.com/chat) " [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/IgorAntun/node-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

This is a node.js chat application powered by SockJS and Express that provides the main functions you'd expect from a chat, such as emojis, private messages, an admin system, etc.

Expand Down
16 changes: 12 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module.exports = {

sendToAll: function(clients, data) {
for(var client in clients) {
if(clients[client].role > 1 && (data.info === 'connection' || data.info === 'disconnection' || data.info === 'update' || data.info === 'clients')) {
data.user.ip = clients[client].ip;
if(clients[client].role > 1 && (data.info === 'connection' || data.info === 'disconnection')) {
data.user.ip = module.exports.getUserByID(clients, data.user.id).ip;
} else if(data.user) {
delete data.user.ip;
}
Expand All @@ -33,7 +33,7 @@ module.exports = {

checkUser: function(clients, user) {
for(var client in clients) {
if(clients[client].un == user) {
if(clients[client].un === user) {
return true;
}
}
Expand All @@ -42,7 +42,15 @@ module.exports = {

getUserByName: function(clients, name) {
for(client in clients) {
if(clients[client].un == name) {
if(clients[client].un === name) {
return clients[client];
}
}
},

getUserByID: function(clients, id) {
for(client in clients) {
if(clients[client].id === id) {
return clients[client];
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-chat",
"version": "1.0.0",
"version": "1.0.3",
"private": true,
"scripts": {
"start": "node app.js"
Expand Down

0 comments on commit 9a55593

Please sign in to comment.