Properly handle avatar changes in group update messages
This commit is contained in:
parent
7789beec64
commit
1e562c8293
2 changed files with 23 additions and 6 deletions
|
@ -19,10 +19,12 @@
|
||||||
|
|
||||||
const { Message: TypedMessage, Contact, PhoneNumber } = Signal.Types;
|
const { Message: TypedMessage, Contact, PhoneNumber } = Signal.Types;
|
||||||
const {
|
const {
|
||||||
|
deleteAttachmentData,
|
||||||
deleteExternalMessageFiles,
|
deleteExternalMessageFiles,
|
||||||
getAbsoluteAttachmentPath,
|
getAbsoluteAttachmentPath,
|
||||||
loadAttachmentData,
|
loadAttachmentData,
|
||||||
loadQuoteData,
|
loadQuoteData,
|
||||||
|
writeNewAttachmentData,
|
||||||
} = window.Signal.Migrations;
|
} = window.Signal.Migrations;
|
||||||
|
|
||||||
window.AccountCache = Object.create(null);
|
window.AccountCache = Object.create(null);
|
||||||
|
@ -1033,28 +1035,43 @@
|
||||||
return conversation.queueJob(async () => {
|
return conversation.queueJob(async () => {
|
||||||
try {
|
try {
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
let attributes = { type: 'private' };
|
let attributes = {
|
||||||
|
...conversation.attributes,
|
||||||
|
};
|
||||||
if (dataMessage.group) {
|
if (dataMessage.group) {
|
||||||
let groupUpdate = null;
|
let groupUpdate = null;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
...attributes,
|
||||||
type: 'group',
|
type: 'group',
|
||||||
groupId: dataMessage.group.id,
|
groupId: dataMessage.group.id,
|
||||||
};
|
};
|
||||||
if (dataMessage.group.type === GROUP_TYPES.UPDATE) {
|
if (dataMessage.group.type === GROUP_TYPES.UPDATE) {
|
||||||
attributes = {
|
attributes = {
|
||||||
type: 'group',
|
...attributes,
|
||||||
groupId: dataMessage.group.id,
|
|
||||||
name: dataMessage.group.name,
|
name: dataMessage.group.name,
|
||||||
avatar: dataMessage.group.avatar,
|
|
||||||
members: _.union(
|
members: _.union(
|
||||||
dataMessage.group.members,
|
dataMessage.group.members,
|
||||||
conversation.get('members')
|
conversation.get('members')
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Update this group conversations's avatar on disk if it has changed.
|
||||||
|
if (dataMessage.group.avatar) {
|
||||||
|
attributes = await window.Signal.Types.Conversation.maybeUpdateAvatar(
|
||||||
|
attributes,
|
||||||
|
dataMessage.group.avatar.data,
|
||||||
|
{
|
||||||
|
writeNewAttachmentData,
|
||||||
|
deleteAttachmentData,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
groupUpdate =
|
groupUpdate =
|
||||||
conversation.changedAttributes(
|
conversation.changedAttributes(
|
||||||
_.pick(dataMessage.group, 'name', 'avatar')
|
_.pick(dataMessage.group, 'name', 'avatar')
|
||||||
) || {};
|
) || {};
|
||||||
|
|
||||||
const difference = _.difference(
|
const difference = _.difference(
|
||||||
attributes.members,
|
attributes.members,
|
||||||
conversation.get('members')
|
conversation.get('members')
|
||||||
|
|
|
@ -119,6 +119,7 @@ function initializeMigrations({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attachmentsPath,
|
attachmentsPath,
|
||||||
|
deleteAttachmentData: deleteOnDisk,
|
||||||
deleteExternalMessageFiles: MessageType.deleteAllExternalFiles({
|
deleteExternalMessageFiles: MessageType.deleteAllExternalFiles({
|
||||||
deleteAttachmentData: Type.deleteData(deleteOnDisk),
|
deleteAttachmentData: Type.deleteData(deleteOnDisk),
|
||||||
deleteOnDisk,
|
deleteOnDisk,
|
||||||
|
@ -131,8 +132,6 @@ function initializeMigrations({
|
||||||
loadMessage: MessageType.createAttachmentLoader(loadAttachmentData),
|
loadMessage: MessageType.createAttachmentLoader(loadAttachmentData),
|
||||||
Migrations0DatabaseWithAttachmentData,
|
Migrations0DatabaseWithAttachmentData,
|
||||||
Migrations1DatabaseWithoutAttachmentData,
|
Migrations1DatabaseWithoutAttachmentData,
|
||||||
writeNewAttachmentData: createWriterForNew(attachmentsPath),
|
|
||||||
deleteAttachmentData: deleteOnDisk,
|
|
||||||
upgradeMessageSchema: (message, options = {}) => {
|
upgradeMessageSchema: (message, options = {}) => {
|
||||||
const { maxVersion } = options;
|
const { maxVersion } = options;
|
||||||
|
|
||||||
|
@ -153,6 +152,7 @@ function initializeMigrations({
|
||||||
writeExistingAttachmentData: createWriterForExisting(attachmentsPath),
|
writeExistingAttachmentData: createWriterForExisting(attachmentsPath),
|
||||||
logger,
|
logger,
|
||||||
}),
|
}),
|
||||||
|
writeNewAttachmentData: createWriterForNew(attachmentsPath),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue