From 516ccd965fa229ac2238a328c0d1f238036d9472 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 12 Mar 2016 11:36:55 +0200 Subject: [PATCH] Add support for IRCv3 server-time --- src/models/msg.js | 7 ++++++- src/plugins/irc-events/join.js | 1 + src/plugins/irc-events/kick.js | 1 + src/plugins/irc-events/message.js | 1 + src/plugins/irc-events/mode.js | 1 + src/plugins/irc-events/nick.js | 1 + src/plugins/irc-events/part.js | 1 + src/plugins/irc-events/quit.js | 1 + src/plugins/irc-events/topic.js | 1 + 9 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/models/msg.js b/src/models/msg.js index d176c8f5..d0c8a0db 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -28,8 +28,13 @@ function Msg(attr) { from: "", id: id++, text: "", - time: new Date(), type: Msg.Type.MESSAGE, self: false }, attr)); + + if (attr.time > 0) { + attr.time = new Date(attr.time); + } else { + attr.time = new Date(); + } } diff --git a/src/plugins/irc-events/join.js b/src/plugins/irc-events/join.js index 4410e9c3..a9bacc80 100644 --- a/src/plugins/irc-events/join.js +++ b/src/plugins/irc-events/join.js @@ -24,6 +24,7 @@ module.exports = function(irc, network) { chan: chan.id }); var msg = new Msg({ + time: data.time, from: data.nick, hostmask: data.ident + "@" + data.hostname, type: Msg.Type.JOIN, diff --git a/src/plugins/irc-events/kick.js b/src/plugins/irc-events/kick.js index 2fb81fc2..d1713e19 100644 --- a/src/plugins/irc-events/kick.js +++ b/src/plugins/irc-events/kick.js @@ -21,6 +21,7 @@ module.exports = function(irc, network) { var msg = new Msg({ type: Msg.Type.KICK, + time: data.time, mode: chan.getMode(data.nick), from: data.nick, target: data.kicked, diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 467ec2ae..dd20e1fd 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -65,6 +65,7 @@ module.exports = function(irc, network) { var msg = new Msg({ type: data.type, + time: data.time, mode: chan.getMode(data.nick), from: data.nick, text: data.msg, diff --git a/src/plugins/irc-events/mode.js b/src/plugins/irc-events/mode.js index d50117a7..fd734439 100644 --- a/src/plugins/irc-events/mode.js +++ b/src/plugins/irc-events/mode.js @@ -24,6 +24,7 @@ module.exports = function(irc, network) { } var msg = new Msg({ + time: data.time, type: Msg.Type.MODE, mode: (targetChan.type !== Chan.Type.LOBBY && targetChan.getMode(data.nick)) || "", from: data.nick, diff --git a/src/plugins/irc-events/nick.js b/src/plugins/irc-events/nick.js index 93926db4..6a810e80 100644 --- a/src/plugins/irc-events/nick.js +++ b/src/plugins/irc-events/nick.js @@ -34,6 +34,7 @@ module.exports = function(irc, network) { chan: chan.id }); var msg = new Msg({ + time: data.time, type: Msg.Type.NICK, mode: chan.getMode(data.newnick), nick: data.nick, diff --git a/src/plugins/irc-events/part.js b/src/plugins/irc-events/part.js index ef1e4467..8043920a 100644 --- a/src/plugins/irc-events/part.js +++ b/src/plugins/irc-events/part.js @@ -23,6 +23,7 @@ module.exports = function(irc, network) { }); var msg = new Msg({ type: Msg.Type.PART, + time: data.time, mode: (user && user.mode) || "", text: data.message || "", hostmask: data.ident + "@" + data.hostname, diff --git a/src/plugins/irc-events/quit.js b/src/plugins/irc-events/quit.js index 87dd2eab..288135af 100644 --- a/src/plugins/irc-events/quit.js +++ b/src/plugins/irc-events/quit.js @@ -15,6 +15,7 @@ module.exports = function(irc, network) { chan: chan.id }); var msg = new Msg({ + time: data.time, type: Msg.Type.QUIT, mode: user.mode || "", text: data.message || "", diff --git a/src/plugins/irc-events/topic.js b/src/plugins/irc-events/topic.js index abf66fbb..0330d139 100644 --- a/src/plugins/irc-events/topic.js +++ b/src/plugins/irc-events/topic.js @@ -10,6 +10,7 @@ module.exports = function(irc, network) { } var msg = new Msg({ + time: data.time, type: Msg.Type.TOPIC, mode: (data.nick && chan.getMode(data.nick)) || "", from: data.nick,