Support reporting token on envelope
This commit is contained in:
parent
dc8d8e529d
commit
486cbe0471
12 changed files with 98 additions and 26 deletions
|
@ -412,6 +412,9 @@ export default class MessageReceiver
|
|||
serverTimestamp,
|
||||
urgent: isBoolean(decoded.urgent) ? decoded.urgent : true,
|
||||
story: decoded.story,
|
||||
reportingToken: decoded.reportingToken?.length
|
||||
? decoded.reportingToken
|
||||
: undefined,
|
||||
};
|
||||
|
||||
// After this point, decoding errors are not the server's
|
||||
|
@ -848,6 +851,9 @@ export default class MessageReceiver
|
|||
item.serverTimestamp || decoded.serverTimestamp?.toNumber(),
|
||||
urgent: isBoolean(item.urgent) ? item.urgent : true,
|
||||
story: Boolean(item.story),
|
||||
reportingToken: item.reportingToken
|
||||
? Bytes.fromBase64(item.reportingToken)
|
||||
: undefined,
|
||||
};
|
||||
|
||||
const { decrypted } = item;
|
||||
|
@ -1123,6 +1129,9 @@ export default class MessageReceiver
|
|||
receivedAtCounter: envelope.receivedAtCounter,
|
||||
urgent: envelope.urgent,
|
||||
story: envelope.story,
|
||||
reportingToken: envelope.reportingToken
|
||||
? Bytes.toBase64(envelope.reportingToken)
|
||||
: undefined,
|
||||
};
|
||||
this.decryptAndCacheBatcher.add({
|
||||
request,
|
||||
|
@ -1262,14 +1271,12 @@ export default class MessageReceiver
|
|||
return;
|
||||
}
|
||||
|
||||
if (envelope.content) {
|
||||
await this.innerHandleContentMessage(envelope, plaintext);
|
||||
|
||||
return;
|
||||
if (!envelope.content) {
|
||||
this.removeFromCache(envelope);
|
||||
throw new Error('Received message with no content');
|
||||
}
|
||||
|
||||
this.removeFromCache(envelope);
|
||||
throw new Error('Received message with no content');
|
||||
await this.innerHandleContentMessage(envelope, plaintext);
|
||||
}
|
||||
|
||||
private async unsealEnvelope(
|
||||
|
|
1
ts/textsecure/Types.d.ts
vendored
1
ts/textsecure/Types.d.ts
vendored
|
@ -97,6 +97,7 @@ export type ProcessedEnvelope = Readonly<{
|
|||
groupId?: string;
|
||||
urgent?: boolean;
|
||||
story?: boolean;
|
||||
reportingToken?: Uint8Array;
|
||||
}>;
|
||||
|
||||
export type ProcessedAttachment = {
|
||||
|
|
|
@ -812,6 +812,12 @@ export type ConfirmCodeOptionsType = Readonly<{
|
|||
accessKey?: Uint8Array;
|
||||
}>;
|
||||
|
||||
export type ReportMessageOptionsType = Readonly<{
|
||||
senderUuid: string;
|
||||
serverGuid: string;
|
||||
token?: string;
|
||||
}>;
|
||||
|
||||
export type WebAPIType = {
|
||||
startRegistration(): unknown;
|
||||
finishRegistration(baton: unknown): void;
|
||||
|
@ -931,7 +937,7 @@ export type WebAPIType = {
|
|||
registerCapabilities: (capabilities: CapabilitiesUploadType) => Promise<void>;
|
||||
registerKeys: (genKeys: KeysType, uuidKind: UUIDKind) => Promise<void>;
|
||||
registerSupportForUnauthenticatedDelivery: () => Promise<void>;
|
||||
reportMessage: (senderUuid: string, serverGuid: string) => Promise<void>;
|
||||
reportMessage: (options: ReportMessageOptionsType) => Promise<void>;
|
||||
requestVerificationSMS: (number: string, token: string) => Promise<void>;
|
||||
requestVerificationVoice: (number: string, token: string) => Promise<void>;
|
||||
checkAccountExistence: (uuid: UUID) => Promise<boolean>;
|
||||
|
@ -1800,15 +1806,19 @@ export function initialize({
|
|||
});
|
||||
}
|
||||
|
||||
async function reportMessage(
|
||||
senderUuid: string,
|
||||
serverGuid: string
|
||||
): Promise<void> {
|
||||
async function reportMessage({
|
||||
senderUuid,
|
||||
serverGuid,
|
||||
token,
|
||||
}: ReportMessageOptionsType): Promise<void> {
|
||||
const jsonData = { token };
|
||||
|
||||
await _ajax({
|
||||
call: 'reportMessage',
|
||||
httpType: 'POST',
|
||||
urlParameters: urlPathFromComponents([senderUuid, serverGuid]),
|
||||
responseType: 'bytes',
|
||||
jsonData,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue