Stickers
Co-authored-by: scott@signal.org Co-authored-by: ken@signal.org
This commit is contained in:
parent
8c8856785b
commit
29de50c12a
100 changed files with 7572 additions and 693 deletions
|
@ -1,6 +1,14 @@
|
|||
/* global Whisper, Signal, setTimeout, clearTimeout, MessageController */
|
||||
/* global
|
||||
ConversationController,
|
||||
Whisper,
|
||||
Signal,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
MessageController
|
||||
*/
|
||||
|
||||
const { isFunction, isNumber, omit } = require('lodash');
|
||||
const { computeHash } = require('./types/conversation');
|
||||
const getGuid = require('uuid/v4');
|
||||
const {
|
||||
getMessageById,
|
||||
|
@ -356,17 +364,41 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) {
|
|||
}
|
||||
|
||||
if (type === 'group-avatar') {
|
||||
const group = message.get('group');
|
||||
if (!group) {
|
||||
throw new Error("_addAttachmentToMessage: group didn't exist");
|
||||
const conversationId = message.get('conversationid');
|
||||
const conversation = ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
logger.warn("_addAttachmentToMessage: conversation didn't exist");
|
||||
}
|
||||
|
||||
const existingAvatar = group.avatar;
|
||||
const existingAvatar = conversation.get('avatar');
|
||||
if (existingAvatar && existingAvatar.path) {
|
||||
await Signal.Migrations.deleteAttachmentData(existingAvatar.path);
|
||||
}
|
||||
|
||||
_replaceAttachment(group, 'avatar', attachment, logPrefix);
|
||||
const data = await Signal.Migrations.loadAttachmentData(attachment.path);
|
||||
conversation.set({
|
||||
avatar: {
|
||||
...attachment,
|
||||
hash: await computeHash(data),
|
||||
},
|
||||
});
|
||||
await Signal.Data.updateConversation(
|
||||
conversationId,
|
||||
conversation.attributes,
|
||||
{
|
||||
Conversation: Whisper.Conversation,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'sticker') {
|
||||
const sticker = message.get('sticker');
|
||||
if (!sticker) {
|
||||
throw new Error("_addAttachmentToMessage: sticker didn't exist");
|
||||
}
|
||||
|
||||
_replaceAttachment(sticker, 'data', attachment, logPrefix);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue