From 7886391fd4ab0859b83bb74387d0456263ff981b Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Sun, 3 Feb 2019 21:54:26 -0500 Subject: [PATCH] Bug 1722212 - Add support for self-messaging. r=IanN --- suite/chatzilla/xul/content/handlers.js | 36 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/suite/chatzilla/xul/content/handlers.js b/suite/chatzilla/xul/content/handlers.js index 416e9ae016..608ab7897b 100644 --- a/suite/chatzilla/xul/content/handlers.js +++ b/suite/chatzilla/xul/content/handlers.js @@ -2953,15 +2953,32 @@ function user_oninit () CIRCUser.prototype.onPrivmsg = function my_cprivmsg(e) { + var sourceObj = e.user; + var destObj = e.server.me; + var displayObj = this; + if (!("messages" in this)) { var limit = client.prefs["newTabLimit"]; if (limit == 0 || client.viewsArray.length < limit) - openQueryTab(e.server, e.user.unicodeName); + { + if (e.user != e.server.me) + { + openQueryTab(e.server, e.user.unicodeName); + } + else + { + // This is a self-message, i.e. we received a message that + // looks like it came from us. Display it accordingly. + sourceObj = e.server.me; + destObj = openQueryTab(e.server, e.params[1]); + displayObj = destObj; + } + } } client.munger.getRule(".mailto").enabled = client.prefs["munger.mailto"]; - this.display(e.decodeParam(2), "PRIVMSG", e.user, e.server.me); + displayObj.display(e.decodeParam(2), "PRIVMSG", sourceObj, destObj); client.munger.getRule(".mailto").enabled = false; } @@ -3004,8 +3021,21 @@ function my_notice (e) } } + var sourceObj = this; + var destObj = e.server.me; + var displayObj = this; + + if (e.user == e.server.me) + { + // This is a self-message, i.e. we received a message that + // looks like it came from us. Display it accordingly. + var sourceObj = e.server.me; + var destObj = e.server.addTarget(e.params[1]); + var displayObj = e.server.parent; + } + client.munger.getRule(".mailto").enabled = displayMailto; - this.display(msg, "NOTICE", this, e.server.me); + displayObj.display(msg, "NOTICE", sourceObj, destObj); client.munger.getRule(".mailto").enabled = false; }