thelounge/src/models/user.js
Pavel Djundik a3e448acf5 Enable no-var rule
Fixes #1961
2018-02-19 19:49:39 +02:00

33 lines
595 B
JavaScript

"use strict";
const _ = require("lodash");
module.exports = User;
function User(attr, prefixLookup) {
_.defaults(this, attr, {
modes: [],
away: "",
mode: "",
nick: "",
lastMessage: 0,
});
this.setModes(this.modes, prefixLookup);
}
User.prototype.setModes = function(modes, prefixLookup) {
// irc-framework sets character mode, but lounge works with symbols
this.modes = modes.map((mode) => prefixLookup[mode]);
this.mode = this.modes[0] || "";
};
User.prototype.toJSON = function() {
return {
nick: this.nick,
mode: this.mode,
lastMessage: this.lastMessage,
};
};