From 16b779e8e24a06706cc80843d3fd5975eb9b0ff8 Mon Sep 17 00:00:00 2001
From: mcmlxxix <>
Date: Fri, 16 Mar 2012 06:54:13 +0000
Subject: [PATCH] use user.alias instead of user.handle to identify. display
 notice on room entry/exit.

---
 exec/load/json-chat.js | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/exec/load/json-chat.js b/exec/load/json-chat.js
index a893d5e18b..d9976fd483 100644
--- a/exec/load/json-chat.js
+++ b/exec/load/json-chat.js
@@ -25,9 +25,9 @@ function JSONChat(usernum,jsonclient,host,port) {
 		if(usernum > 0 && system.username(usernum)) 
 			usr = new User(usernum);
 		if(usr) 
-			this.nick = new Nick(usr.handle,system.name,usr.ip_address);
+			this.nick = new Nick(usr.alias,system.name,usr.ip_address);
 		else if(user && user.number > 0)
-			this.nick = new Nick(user.handle,system.name,user.ip_address);
+			this.nick = new Nick(user.alias,system.name,user.ip_address);
 		if(this.nick)
 			this.client.subscribe("chat","channels." + this.nick.name + ".messages");
 		else
@@ -88,25 +88,38 @@ function JSONChat(usernum,jsonclient,host,port) {
 	/* pass any client update packets to this function to process inbound messages/status updates */
 	this.update = function(packet) {
 		var arr = packet.location.split(".");
-		if(arr.shift().toUpperCase() != "CHAT") 
-			return false;
-			
 		var channel;
 		var usr;
-		
+		var message;
+			
 		while(arr.length > 0) {
 			switch(arr.shift().toUpperCase()) {
 			case "CHANNELS":
 				channel = this.channels[arr[0].toUpperCase()];
 				break;
 			case "MESSAGES":
-				channel.messages.push(packet.data);
+				message = packet.data;
 				break;
 			case "USERS":
 				usr = channel.users[arr[0].toUpperCase()];
 				break;
 			}
 		}
+		
+		switch(packet.oper.toUpperCase()) {
+		case "SUBSCRIBE":
+			channel.messages.push(new Message("",packet.data.nick + " is here.",Date.now()));
+			break;
+		case "UNSUBSCRIBE":
+			channel.messages.push(new Message("",packet.data.nick + " has left.",Date.now()));
+			break;
+		case "WRITE":
+			channel.messages.push(message);
+			break;
+		default:
+			log(LOG_WARNING,"Unhandled response");
+			break;
+		}
 		return true;
 	}
 	
@@ -152,7 +165,7 @@ function JSONChat(usernum,jsonclient,host,port) {
 		case "WHO":
 			var users = this.who(target);
 			for(var u in users)
-				this.channels[target.toUpperCase()].messages.push(users[u]);
+				this.channels[target.toUpperCase()].users.push(users[u]);
 			break;
 		case "INVITE":
 			break;
-- 
GitLab