1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DMDataMessage = void 0;
const User_1 = require("./User");
const DMMessage_1 = require("./DMMessage");
const DM_1 = require("./DM");
const Attachment_1 = require("./Attachment");
const QuoteMessage_1 = require("./QuoteMessage");
const CLIDispatcher_1 = require("./CLIDispatcher");
const MessageReceipt_1 = require("../enums/MessageReceipt");
const MessageFormatting_1 = require("./MessageFormatting");
const UserMention_1 = require("./UserMention");
const UserDataType_1 = require("../enums/UserDataType");
const ReceivedURLPreview_1 = require("./ReceivedURLPreview");
/**
* A data message as sent by Signal
*/
class DMDataMessage extends DMMessage_1.DMMessage {
constructor(user, data, time, client) {
super(user, time, new DM_1.DM(user.uuid, user.number, client), client, data.expiresInSeconds);
this.attachments = [];
this.mentions = [];
this.previews = [];
this.content = data.message && data.message.trim().length > 0 ? data.message : null;
if (data.quote)
this.quote = new QuoteMessage_1.QuoteMessage(data.quote);
this.attachments = data.attachments?.map(i => new Attachment_1.Attachment(i));
this.formatting = new MessageFormatting_1.MessageFormatting(data.message && data.message.trim().length > 0 ? data.message : "", data.textStyles);
this.mentions = data.mentions?.map(mention => new UserMention_1.UserMention(new User_1.User(UserDataType_1.UserDataType.Mention, mention), mention.start, mention.length));
this.previews = data.previews?.map(preview => (new ReceivedURLPreview_1.ReceivedURLPreview(preview)).build());
}
async markAsRead() {
await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", {
recipient: this.author.number,
targetTimestamp: this.createdTimestamp,
type: MessageReceipt_1.MessageReceipt.Read
}, this.client.process);
}
async markAsViewed() {
await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", {
recipient: this.author.number,
targetTimestamp: this.createdTimestamp,
type: MessageReceipt_1.MessageReceipt.Viewed
}, this.client.process);
}
}
exports.DMDataMessage = DMDataMessage;
//# sourceMappingURL=DMDataMessage.js.map
|