Fix #116: Move 'you' handling in invites to the client

This commit is contained in:
Pavel Djundik 2016-02-28 10:21:19 +02:00
parent f8eb50260f
commit f6563d0ea9
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,9 @@
<a href="#" class="user">{{from}}</a> <a href="#" class="user">{{from}}</a>
invited invited
<a href="#" class="user">{{target}}</a> {{#if invitedYou}}
you
{{else}}
<a href="#" class="user">{{target}}</a>
{{/if}}
to to
{{{parse text}}} {{{parse text}}}

View File

@ -5,9 +5,6 @@ module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("invite", function(data) { irc.on("invite", function(data) {
var target = data.to; var target = data.to;
if (target.toLowerCase() === irc.me.toLowerCase()) {
target = "you";
}
var chan = _.find(network.channels, {name: data.channel}); var chan = _.find(network.channels, {name: data.channel});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
@ -18,7 +15,8 @@ module.exports = function(irc, network) {
type: Msg.Type.INVITE, type: Msg.Type.INVITE,
from: data.from, from: data.from,
target: target, target: target,
text: data.channel text: data.channel,
invitedYou: target.toLowerCase() === irc.me.toLowerCase()
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {