mirror of
https://github.com/thelounge/thelounge
synced 2024-12-24 11:23:07 +00:00
22 lines
546 B
JavaScript
22 lines
546 B
JavaScript
var _ = require("lodash");
|
|
var Chan = require("../models/chan");
|
|
var User = require("../models/user");
|
|
|
|
module.exports = function(client, sockets) {
|
|
var network = this;
|
|
client.on("names", function(data) {
|
|
var chan = _.findWhere(network.channels, {name: data.channel});
|
|
if (typeof chan === "undefined") {
|
|
return;
|
|
}
|
|
chan.users = [];
|
|
_.each(data.names, function(n) {
|
|
chan.addUser(new User(n));
|
|
});
|
|
chan.sortUsers();
|
|
sockets.in("chat").emit("users", {
|
|
id: chan.id,
|
|
users: chan.users,
|
|
});
|
|
});
|
|
};
|