Link Previews
This commit is contained in:
parent
91ef39e482
commit
813924685e
36 changed files with 2298 additions and 134 deletions
|
@ -759,6 +759,7 @@
|
|||
const { getName } = Contact;
|
||||
const contact = quotedMessage.getContact();
|
||||
const attachments = quotedMessage.get('attachments');
|
||||
const preview = quotedMessage.get('preview');
|
||||
|
||||
const body = quotedMessage.get('body');
|
||||
const embeddedContact = quotedMessage.get('contact');
|
||||
|
@ -767,32 +768,45 @@
|
|||
? getName(embeddedContact[0])
|
||||
: '';
|
||||
|
||||
const media =
|
||||
attachments && attachments.length ? attachments : preview || [];
|
||||
|
||||
return {
|
||||
author: contact.id,
|
||||
id: quotedMessage.get('sent_at'),
|
||||
text: body || embeddedContactName,
|
||||
attachments: await Promise.all(
|
||||
(attachments || []).map(async attachment => {
|
||||
const { contentType, fileName, thumbnail } = attachment;
|
||||
media
|
||||
.filter(
|
||||
attachment =>
|
||||
(attachment && attachment.thumbnail) || attachment.message
|
||||
)
|
||||
.map(async attachment => {
|
||||
const { fileName } = attachment;
|
||||
|
||||
return {
|
||||
contentType,
|
||||
// Our protos library complains about this field being undefined, so we
|
||||
// force it to null
|
||||
fileName: fileName || null,
|
||||
thumbnail: thumbnail
|
||||
? {
|
||||
...(await loadAttachmentData(thumbnail)),
|
||||
objectUrl: getAbsoluteAttachmentPath(thumbnail.path),
|
||||
}
|
||||
: null,
|
||||
};
|
||||
})
|
||||
const thumbnail = attachment.thumbnail || attachment.image;
|
||||
const contentType =
|
||||
attachment.contentType ||
|
||||
(attachment.image && attachment.image.contentType);
|
||||
|
||||
return {
|
||||
contentType,
|
||||
// Our protos library complains about this field being undefined, so we
|
||||
// force it to null
|
||||
fileName: fileName || null,
|
||||
thumbnail: thumbnail
|
||||
? {
|
||||
...(await loadAttachmentData(thumbnail)),
|
||||
objectUrl: getAbsoluteAttachmentPath(thumbnail.path),
|
||||
}
|
||||
: null,
|
||||
};
|
||||
})
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
sendMessage(body, attachments, quote) {
|
||||
sendMessage(body, attachments, quote, preview) {
|
||||
this.clearTypingTimers();
|
||||
|
||||
const destination = this.id;
|
||||
|
@ -819,6 +833,7 @@
|
|||
body,
|
||||
conversationId: destination,
|
||||
quote,
|
||||
preview,
|
||||
attachments,
|
||||
sent_at: now,
|
||||
received_at: now,
|
||||
|
@ -885,6 +900,7 @@
|
|||
body,
|
||||
attachmentsWithData,
|
||||
quote,
|
||||
preview,
|
||||
now,
|
||||
expireTimer,
|
||||
profileKey,
|
||||
|
@ -1621,7 +1637,7 @@
|
|||
const { attributes } = message;
|
||||
const { schemaVersion } = attributes;
|
||||
|
||||
if (schemaVersion < Message.CURRENT_SCHEMA_VERSION) {
|
||||
if (schemaVersion < Message.VERSION_NEEDED_FOR_DISPLAY) {
|
||||
// Yep, we really do want to wait for each of these
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const upgradedMessage = await upgradeMessageSchema(attributes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue