Page MenuHomePhabricator

D13413.id44378.diff
No OneTemporary

D13413.id44378.diff

diff --git a/lib/shared/dm-ops/change-thread-settings-spec.js b/lib/shared/dm-ops/change-thread-settings-spec.js
--- a/lib/shared/dm-ops/change-thread-settings-spec.js
+++ b/lib/shared/dm-ops/change-thread-settings-spec.js
@@ -8,6 +8,7 @@
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
import type {
+ DMBlobOperation,
DMChangeThreadSettingsOperation,
DMThreadSettingsChanges,
} from '../../types/dm-ops.js';
@@ -20,6 +21,7 @@
} from '../../types/minimally-encoded-thread-permissions-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type { ClientUpdateInfo } from '../../types/update-types.js';
+import { blobHashFromBlobServiceURI } from '../../utils/blob-service.js';
import { values } from '../../utils/objects.js';
import { rawMessageInfoFromMessageData } from '../message-utils.js';
@@ -92,6 +94,32 @@
return { fieldNameToMessageData, threadInfoUpdate };
}
+function getBlobOpsFromOperation(
+ dmOperation: DMChangeThreadSettingsOperation,
+ threadInfo: ?RawThreadInfo,
+): Array<DMBlobOperation> {
+ const ops: Array<DMBlobOperation> = [];
+
+ const prevAvatar = threadInfo?.avatar;
+ if (prevAvatar && prevAvatar.type === 'encrypted_image') {
+ ops.push({
+ type: 'remove_holder',
+ blobHash: blobHashFromBlobServiceURI(prevAvatar.blobURI),
+ dmOpType: 'inbound_and_outbound',
+ });
+ }
+
+ const { avatar } = dmOperation.changes;
+ if (avatar && avatar?.type === 'encrypted_image') {
+ ops.push({
+ type: 'establish_holder',
+ blobHash: blobHashFromBlobServiceURI(avatar.blobURI),
+ dmOpType: 'inbound_only',
+ });
+ }
+ return ops;
+}
+
const changeThreadSettingsSpec: DMOperationSpec<DMChangeThreadSettingsOperation> =
Object.freeze({
notificationsCreationData: async (
@@ -119,6 +147,8 @@
const { fieldNameToMessageData, threadInfoUpdate } =
createChangeSettingsMessageDatasAndUpdate(dmOperation);
+ const blobOps = getBlobOpsFromOperation(dmOperation, threadInfo);
+
const fieldNameToMessageDataPairs = Object.entries(
fieldNameToMessageData,
);
@@ -159,7 +189,7 @@
return {
rawMessageInfos,
updateInfos,
- blobOps: [],
+ blobOps,
};
},
canBeProcessed: async (

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 2:23 PM (18 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694870
Default Alt Text
D13413.id44378.diff (2 KB)

Event Timeline