Admin Delete

This commit is contained in:
Jamie
2026-02-27 11:55:02 -08:00
committed by Yash
parent b71b5570d3
commit e424610cc2
67 changed files with 2328 additions and 569 deletions

View File

@@ -202,6 +202,12 @@ export const singleProtoJobDataSchema = z.object({
export type SingleProtoJobData = z.infer<typeof singleProtoJobDataSchema>;
export type SendDeleteForEveryoneType = Readonly<{
isAdminDelete: boolean;
targetSentTimestamp: number;
targetAuthorAci: AciString;
}>;
export type SharedMessageOptionsType = Readonly<{
// required
timestamp: number;
@@ -210,7 +216,7 @@ export type SharedMessageOptionsType = Readonly<{
body?: string;
bodyRanges?: ReadonlyArray<RawBodyRange>;
contact?: ReadonlyArray<EmbeddedContactWithUploadedAvatar>;
deletedForEveryoneTimestamp?: number;
deleteForEveryone?: SendDeleteForEveryoneType;
expireTimer?: DurationInSeconds;
flags?: number;
groupCallUpdate?: GroupCallUpdateType;
@@ -306,7 +312,7 @@ class Message {
dataMessage?: Proto.DataMessage;
deletedForEveryoneTimestamp?: number;
deleteForEveryone?: SendDeleteForEveryoneType;
groupCallUpdate?: GroupCallUpdateType;
@@ -333,7 +339,7 @@ class Message {
this.pollCreate = options.pollCreate;
this.pollTerminate = options.pollTerminate;
this.timestamp = options.timestamp;
this.deletedForEveryoneTimestamp = options.deletedForEveryoneTimestamp;
this.deleteForEveryone = options.deleteForEveryone;
this.groupCallUpdate = options.groupCallUpdate;
this.storyContext = options.storyContext;
// Polls
@@ -609,10 +615,19 @@ class Message {
if (this.isViewOnce) {
proto.isViewOnce = true;
}
if (this.deletedForEveryoneTimestamp) {
proto.delete = {
targetSentTimestamp: Long.fromNumber(this.deletedForEveryoneTimestamp),
};
if (this.deleteForEveryone) {
const { isAdminDelete, targetSentTimestamp, targetAuthorAci } =
this.deleteForEveryone;
if (isAdminDelete) {
proto.adminDelete = {
targetSentTimestamp: Long.fromNumber(targetSentTimestamp),
targetAuthorAciBinary: uuidToBytes(targetAuthorAci),
};
} else {
proto.delete = {
targetSentTimestamp: Long.fromNumber(targetSentTimestamp),
};
}
}
if (this.bodyRanges) {
proto.requiredProtocolVersion =
@@ -1144,10 +1159,10 @@ export class MessageSender {
options: Readonly<GroupMessageOptionsType>
): MessageOptionsType {
const {
deleteForEveryone,
attachments,
bodyRanges,
contact,
deletedForEveryoneTimestamp,
expireTimer,
flags,
groupCallUpdate,
@@ -1191,11 +1206,11 @@ export class MessageSender {
);
return {
deleteForEveryone,
attachments,
bodyRanges,
body,
contact,
deletedForEveryoneTimestamp,
expireTimer,
expireTimerVersion: undefined,
flags,

View File

@@ -212,6 +212,11 @@ export type ProcessedDelete = {
targetSentTimestamp?: number;
};
export type ProcessedAdminDelete = Readonly<{
targetSentTimestamp: number;
targetAuthorAci: AciString;
}>;
export type ProcessedBodyRange = RawBodyRange;
export type ProcessedGroupCallUpdate = Proto.DataMessage.IGroupCallUpdate;
@@ -259,6 +264,7 @@ export type ProcessedDataMessage = {
pollVote?: ProcessedPollVote;
pollTerminate?: ProcessedPollTerminate;
delete?: ProcessedDelete;
adminDelete?: ProcessedAdminDelete;
bodyRanges?: ReadonlyArray<ProcessedBodyRange>;
groupCallUpdate?: ProcessedGroupCallUpdate;
storyContext?: ProcessedStoryContext;

View File

@@ -29,6 +29,7 @@ import type {
ProcessedPollVote,
ProcessedPollTerminate,
ProcessedDelete,
ProcessedAdminDelete,
ProcessedGiftBadge,
ProcessedStoryContext,
ProcessedPinMessage,
@@ -424,6 +425,25 @@ export function processDelete(
};
}
export function processAdminDelete(
adminDelete?: Proto.DataMessage.IAdminDelete | null
): ProcessedAdminDelete | undefined {
if (!adminDelete) {
return undefined;
}
const targetSentTimestamp = adminDelete.targetSentTimestamp?.toNumber();
strictAssert(targetSentTimestamp, 'AdminDelete missing targetSentTimestamp');
const targetAuthorAci = fromAciUuidBytes(adminDelete.targetAuthorAciBinary);
strictAssert(targetAuthorAci, 'AdminDelete missing targetAuthorAciBinary');
return {
targetSentTimestamp,
targetAuthorAci,
};
}
export function processGiftBadge(
giftBadge: Proto.DataMessage.IGiftBadge | null | undefined
): ProcessedGiftBadge | undefined {
@@ -534,6 +554,7 @@ export function processDataMessage(
pollVote: processPollVote(message.pollVote),
pollTerminate: processPollTerminate(message.pollTerminate),
delete: processDelete(message.delete),
adminDelete: processAdminDelete(message.adminDelete),
bodyRanges: filterAndClean(message.bodyRanges),
groupCallUpdate: dropNull(message.groupCallUpdate),
storyContext: processStoryContext(message.storyContext),