mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-24 08:10:15 +02:00
- Load up to 5 previews per message (to avoid abuse) - Do not load multiple times the same URL - Prepare preview containers per message instead of appending (to maintain correct order) - Store an array of previews instead of a single preview in `Msg` objects - Consolidate preview rendering for new messages and upon refresh/load history (when rendering entire channels) - Update `parse` tests to reflect previous point - Add test for multiple URLs - Switch preview tests from `assert` API to `expect` API
46 lines
665 B
JavaScript
46 lines
665 B
JavaScript
"use strict";
|
|
|
|
var _ = require("lodash");
|
|
|
|
Msg.Type = {
|
|
UNHANDLED: "unhandled",
|
|
ACTION: "action",
|
|
ERROR: "error",
|
|
INVITE: "invite",
|
|
JOIN: "join",
|
|
KICK: "kick",
|
|
MESSAGE: "message",
|
|
MODE: "mode",
|
|
MOTD: "motd",
|
|
NICK: "nick",
|
|
NOTICE: "notice",
|
|
PART: "part",
|
|
QUIT: "quit",
|
|
CTCP: "ctcp",
|
|
TOPIC: "topic",
|
|
TOPIC_SET_BY: "topic_set_by",
|
|
WHOIS: "whois",
|
|
BANLIST: "ban_list"
|
|
};
|
|
|
|
module.exports = Msg;
|
|
|
|
var id = 0;
|
|
|
|
function Msg(attr) {
|
|
_.defaults(this, attr, {
|
|
from: "",
|
|
id: id++,
|
|
previews: [],
|
|
text: "",
|
|
type: Msg.Type.MESSAGE,
|
|
self: false
|
|
});
|
|
|
|
if (this.time > 0) {
|
|
this.time = new Date(this.time);
|
|
} else {
|
|
this.time = new Date();
|
|
}
|
|
}
|