mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-12 02:32:18 +02:00
5ce67ba093
Don't sort queries/users after special chans Set all users in tests to be of type query Add test for not inserting infront of lobby Break after finding the index, otherwise it always adds it to the end Add checking for lobby in first test Fix off-by-one error on the frontend Fix utterly idiotic issue adding a duplicate of the channel we are on rather than the new user when we query Check that we always insert before first special chan
48 lines
1 KiB
JavaScript
48 lines
1 KiB
JavaScript
"use strict";
|
|
|
|
const Chan = require("../../models/chan");
|
|
const Msg = require("../../models/msg");
|
|
|
|
module.exports = function(irc, network) {
|
|
const client = this;
|
|
irc.on("whois", function(data) {
|
|
let chan = network.getChannel(data.nick);
|
|
|
|
if (typeof chan === "undefined") {
|
|
chan = new Chan({
|
|
type: Chan.Type.QUERY,
|
|
name: data.nick,
|
|
});
|
|
|
|
client.emit("join", {
|
|
shouldOpen: true,
|
|
network: network.id,
|
|
chan: chan.getFilteredClone(true),
|
|
index: network.addChannel(chan),
|
|
});
|
|
chan.loadMessages(client, network);
|
|
client.save();
|
|
}
|
|
|
|
let msg;
|
|
|
|
if (data.error) {
|
|
msg = new Msg({
|
|
type: Msg.Type.ERROR,
|
|
text: "No such nick: " + data.nick,
|
|
});
|
|
} else {
|
|
// Absolute datetime in milliseconds since nick is idle
|
|
data.idleTime = Date.now() - data.idle * 1000;
|
|
// Absolute datetime in milliseconds when nick logged on.
|
|
data.logonTime = data.logon * 1000;
|
|
msg = new Msg({
|
|
type: Msg.Type.WHOIS,
|
|
whois: data,
|
|
});
|
|
}
|
|
|
|
chan.pushMessage(client, msg);
|
|
});
|
|
};
|