Mark many of SendMessage's arguments as readonly
This commit is contained in:
parent
93f60ee5a6
commit
8775c711ae
2 changed files with 119 additions and 107 deletions
|
@ -112,7 +112,7 @@ export default class OutgoingMessage {
|
||||||
|
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
|
||||||
identifiers: Array<string>;
|
identifiers: ReadonlyArray<string>;
|
||||||
|
|
||||||
message: Proto.Content | PlaintextContent;
|
message: Proto.Content | PlaintextContent;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ export default class OutgoingMessage {
|
||||||
callback: (result: CallbackResultType) => void;
|
callback: (result: CallbackResultType) => void;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
identifiers: Array<string>;
|
identifiers: ReadonlyArray<string>;
|
||||||
message: Proto.Content | Proto.DataMessage | PlaintextContent;
|
message: Proto.Content | Proto.DataMessage | PlaintextContent;
|
||||||
options?: OutgoingMessageOptionsType;
|
options?: OutgoingMessageOptionsType;
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
|
|
|
@ -120,7 +120,7 @@ export type AttachmentType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MessageOptionsType = {
|
export type MessageOptionsType = {
|
||||||
attachments?: Array<AttachmentType> | null;
|
attachments?: ReadonlyArray<AttachmentType> | null;
|
||||||
body?: string;
|
body?: string;
|
||||||
expireTimer?: number;
|
expireTimer?: number;
|
||||||
flags?: number;
|
flags?: number;
|
||||||
|
@ -130,10 +130,10 @@ export type MessageOptionsType = {
|
||||||
};
|
};
|
||||||
groupV2?: GroupV2InfoType;
|
groupV2?: GroupV2InfoType;
|
||||||
needsSync?: boolean;
|
needsSync?: boolean;
|
||||||
preview?: Array<PreviewType> | null;
|
preview?: ReadonlyArray<PreviewType> | null;
|
||||||
profileKey?: ArrayBuffer;
|
profileKey?: ArrayBuffer;
|
||||||
quote?: any;
|
quote?: any;
|
||||||
recipients: Array<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
sticker?: any;
|
sticker?: any;
|
||||||
reaction?: any;
|
reaction?: any;
|
||||||
deletedForEveryoneTimestamp?: number;
|
deletedForEveryoneTimestamp?: number;
|
||||||
|
@ -162,7 +162,7 @@ export type GroupSendOptionsType = {
|
||||||
const FIXMEU8 = Uint8Array;
|
const FIXMEU8 = Uint8Array;
|
||||||
|
|
||||||
class Message {
|
class Message {
|
||||||
attachments: Array<any>;
|
attachments: ReadonlyArray<any>;
|
||||||
|
|
||||||
body?: string;
|
body?: string;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ class Message {
|
||||||
bodyRanges?: BodyRangesType;
|
bodyRanges?: BodyRangesType;
|
||||||
};
|
};
|
||||||
|
|
||||||
recipients: Array<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
|
|
||||||
sticker?: any;
|
sticker?: any;
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ export default class MessageSender {
|
||||||
return new FIXMEU8(getRandomBytes(paddingLength));
|
return new FIXMEU8(getRandomBytes(paddingLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
getPaddedAttachment(data: ArrayBuffer): ArrayBuffer {
|
getPaddedAttachment(data: Readonly<ArrayBuffer>): ArrayBuffer {
|
||||||
const size = data.byteLength;
|
const size = data.byteLength;
|
||||||
const paddedSize = this._getAttachmentSizeBucket(size);
|
const paddedSize = this._getAttachmentSizeBucket(size);
|
||||||
const padding = getZeroes(paddedSize - size);
|
const padding = getZeroes(paddedSize - size);
|
||||||
|
@ -495,7 +495,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async makeAttachmentPointer(
|
async makeAttachmentPointer(
|
||||||
attachment: AttachmentType
|
attachment: Readonly<AttachmentType>
|
||||||
): Promise<Proto.IAttachmentPointer> {
|
): Promise<Proto.IAttachmentPointer> {
|
||||||
assert(
|
assert(
|
||||||
typeof attachment === 'object' && attachment !== null,
|
typeof attachment === 'object' && attachment !== null,
|
||||||
|
@ -643,12 +643,16 @@ export default class MessageSender {
|
||||||
|
|
||||||
// Proto assembly
|
// Proto assembly
|
||||||
|
|
||||||
async getDataMessage(options: MessageOptionsType): Promise<ArrayBuffer> {
|
async getDataMessage(
|
||||||
|
options: Readonly<MessageOptionsType>
|
||||||
|
): Promise<ArrayBuffer> {
|
||||||
const message = await this.getHydratedMessage(options);
|
const message = await this.getHydratedMessage(options);
|
||||||
return message.toArrayBuffer();
|
return message.toArrayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getContentMessage(options: MessageOptionsType): Promise<Proto.Content> {
|
async getContentMessage(
|
||||||
|
options: Readonly<MessageOptionsType>
|
||||||
|
): Promise<Proto.Content> {
|
||||||
const message = await this.getHydratedMessage(options);
|
const message = await this.getHydratedMessage(options);
|
||||||
const dataMessage = message.toProto();
|
const dataMessage = message.toProto();
|
||||||
|
|
||||||
|
@ -658,7 +662,9 @@ export default class MessageSender {
|
||||||
return contentMessage;
|
return contentMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getHydratedMessage(attributes: MessageOptionsType): Promise<Message> {
|
async getHydratedMessage(
|
||||||
|
attributes: Readonly<MessageOptionsType>
|
||||||
|
): Promise<Message> {
|
||||||
const message = new Message(attributes);
|
const message = new Message(attributes);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.uploadAttachments(message),
|
this.uploadAttachments(message),
|
||||||
|
@ -670,13 +676,15 @@ export default class MessageSender {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTypingContentMessage(options: {
|
getTypingContentMessage(
|
||||||
recipientId?: string;
|
options: Readonly<{
|
||||||
groupId?: ArrayBuffer;
|
recipientId?: string;
|
||||||
groupMembers: Array<string>;
|
groupId?: ArrayBuffer;
|
||||||
isTyping: boolean;
|
groupMembers: ReadonlyArray<string>;
|
||||||
timestamp?: number;
|
isTyping: boolean;
|
||||||
}): Proto.Content {
|
timestamp?: number;
|
||||||
|
}>
|
||||||
|
): Proto.Content {
|
||||||
const ACTION_ENUM = Proto.TypingMessage.Action;
|
const ACTION_ENUM = Proto.TypingMessage.Action;
|
||||||
const { recipientId, groupId, isTyping, timestamp } = options;
|
const { recipientId, groupId, isTyping, timestamp } = options;
|
||||||
|
|
||||||
|
@ -702,7 +710,9 @@ export default class MessageSender {
|
||||||
return contentMessage;
|
return contentMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAttrsFromGroupOptions(options: GroupSendOptionsType): MessageOptionsType {
|
getAttrsFromGroupOptions(
|
||||||
|
options: Readonly<GroupSendOptionsType>
|
||||||
|
): MessageOptionsType {
|
||||||
const {
|
const {
|
||||||
messageText,
|
messageText,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
@ -789,12 +799,12 @@ export default class MessageSender {
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
messageOptions: MessageOptionsType;
|
messageOptions: MessageOptionsType;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const message = new Message(messageOptions);
|
const message = new Message(messageOptions);
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
@ -834,16 +844,16 @@ export default class MessageSender {
|
||||||
recipients,
|
recipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
}: {
|
}: Readonly<{
|
||||||
callback: (result: CallbackResultType) => void;
|
callback: (result: CallbackResultType) => void;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
proto: Proto.Content | Proto.DataMessage | PlaintextContent;
|
proto: Proto.Content | Proto.DataMessage | PlaintextContent;
|
||||||
recipients: Array<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}): void {
|
}>): void {
|
||||||
const rejections = window.textsecure.storage.get(
|
const rejections = window.textsecure.storage.get(
|
||||||
'signedKeyRotationRejected',
|
'signedKeyRotationRejected',
|
||||||
0
|
0
|
||||||
|
@ -878,14 +888,14 @@ export default class MessageSender {
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
recipients: Array<string>;
|
recipients: Array<string>;
|
||||||
proto: Proto.Content | Proto.DataMessage | PlaintextContent;
|
proto: Proto.Content | Proto.DataMessage | PlaintextContent;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const callback = (result: CallbackResultType) => {
|
const callback = (result: CallbackResultType) => {
|
||||||
if (result && result.errors && result.errors.length > 0) {
|
if (result && result.errors && result.errors.length > 0) {
|
||||||
|
@ -914,13 +924,13 @@ export default class MessageSender {
|
||||||
timestamp,
|
timestamp,
|
||||||
contentHint,
|
contentHint,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
identifier: string | undefined;
|
identifier: string | undefined;
|
||||||
proto: Proto.DataMessage | Proto.Content | PlaintextContent;
|
proto: Proto.DataMessage | Proto.Content | PlaintextContent;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
assert(identifier, "Identifier can't be undefined");
|
assert(identifier, "Identifier can't be undefined");
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const callback = (res: CallbackResultType) => {
|
const callback = (res: CallbackResultType) => {
|
||||||
|
@ -959,12 +969,12 @@ export default class MessageSender {
|
||||||
groupId,
|
groupId,
|
||||||
profileKey,
|
profileKey,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
identifier: string;
|
identifier: string;
|
||||||
messageText: string | undefined;
|
messageText: string | undefined;
|
||||||
attachments: Array<AttachmentType> | undefined;
|
attachments: ReadonlyArray<AttachmentType> | undefined;
|
||||||
quote: unknown;
|
quote: unknown;
|
||||||
preview: Array<PreviewType> | undefined;
|
preview: ReadonlyArray<PreviewType> | undefined;
|
||||||
sticker: unknown;
|
sticker: unknown;
|
||||||
reaction: unknown;
|
reaction: unknown;
|
||||||
deletedForEveryoneTimestamp: number | undefined;
|
deletedForEveryoneTimestamp: number | undefined;
|
||||||
|
@ -974,7 +984,7 @@ export default class MessageSender {
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
profileKey?: ArrayBuffer;
|
profileKey?: ArrayBuffer;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
return this.sendMessage({
|
return this.sendMessage({
|
||||||
messageOptions: {
|
messageOptions: {
|
||||||
recipients: [identifier],
|
recipients: [identifier],
|
||||||
|
@ -1009,7 +1019,7 @@ export default class MessageSender {
|
||||||
conversationIdsWithSealedSender = new Set(),
|
conversationIdsWithSealedSender = new Set(),
|
||||||
isUpdate,
|
isUpdate,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
encodedDataMessage: ArrayBuffer;
|
encodedDataMessage: ArrayBuffer;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
destination: string | undefined;
|
destination: string | undefined;
|
||||||
|
@ -1019,7 +1029,7 @@ export default class MessageSender {
|
||||||
conversationIdsWithSealedSender?: Set<string>;
|
conversationIdsWithSealedSender?: Set<string>;
|
||||||
isUpdate?: boolean;
|
isUpdate?: boolean;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
|
||||||
|
@ -1085,7 +1095,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequestBlockSyncMessage(
|
async sendRequestBlockSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1109,7 +1119,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequestConfigurationSyncMessage(
|
async sendRequestConfigurationSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1133,7 +1143,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequestGroupSyncMessage(
|
async sendRequestGroupSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1157,7 +1167,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequestContactSyncMessage(
|
async sendRequestContactSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1181,7 +1191,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendFetchManifestSyncMessage(
|
async sendFetchManifestSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
|
@ -1206,7 +1216,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendFetchLocalProfileSyncMessage(
|
async sendFetchLocalProfileSyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
|
@ -1231,7 +1241,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequestKeySyncMessage(
|
async sendRequestKeySyncMessage(
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
|
@ -1256,12 +1266,12 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async syncReadMessages(
|
async syncReadMessages(
|
||||||
reads: Array<{
|
reads: ReadonlyArray<{
|
||||||
senderUuid?: string;
|
senderUuid?: string;
|
||||||
senderE164?: string;
|
senderE164?: string;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}>,
|
}>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1291,7 +1301,7 @@ export default class MessageSender {
|
||||||
sender: string | undefined,
|
sender: string | undefined,
|
||||||
senderUuid: string,
|
senderUuid: string,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1321,13 +1331,13 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async syncMessageRequestResponse(
|
async syncMessageRequestResponse(
|
||||||
responseArgs: {
|
responseArgs: Readonly<{
|
||||||
threadE164?: string;
|
threadE164?: string;
|
||||||
threadUuid?: string;
|
threadUuid?: string;
|
||||||
groupId?: ArrayBuffer;
|
groupId?: ArrayBuffer;
|
||||||
type: number;
|
type: number;
|
||||||
},
|
}>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1362,12 +1372,12 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendStickerPackSync(
|
async sendStickerPackSync(
|
||||||
operations: Array<{
|
operations: ReadonlyArray<{
|
||||||
packId: string;
|
packId: string;
|
||||||
packKey: string;
|
packKey: string;
|
||||||
installed: boolean;
|
installed: boolean;
|
||||||
}>,
|
}>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1405,8 +1415,8 @@ export default class MessageSender {
|
||||||
destinationE164: string | undefined,
|
destinationE164: string | undefined,
|
||||||
destinationUuid: string | undefined,
|
destinationUuid: string | undefined,
|
||||||
state: number,
|
state: number,
|
||||||
identityKey: ArrayBuffer,
|
identityKey: Readonly<ArrayBuffer>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -1462,9 +1472,9 @@ export default class MessageSender {
|
||||||
// Sending messages to contacts
|
// Sending messages to contacts
|
||||||
|
|
||||||
async sendProfileKeyUpdate(
|
async sendProfileKeyUpdate(
|
||||||
profileKey: ArrayBuffer,
|
profileKey: Readonly<ArrayBuffer>,
|
||||||
recipients: Array<string>,
|
recipients: ReadonlyArray<string>,
|
||||||
options: SendOptionsType,
|
options: Readonly<SendOptionsType>,
|
||||||
groupId?: string
|
groupId?: string
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
||||||
|
@ -1492,8 +1502,8 @@ export default class MessageSender {
|
||||||
|
|
||||||
async sendCallingMessage(
|
async sendCallingMessage(
|
||||||
recipientId: string,
|
recipientId: string,
|
||||||
callingMessage: Proto.ICallingMessage,
|
callingMessage: Readonly<Proto.ICallingMessage>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const recipients = [recipientId];
|
const recipients = [recipientId];
|
||||||
const finalTimestamp = Date.now();
|
const finalTimestamp = Date.now();
|
||||||
|
@ -1518,12 +1528,12 @@ export default class MessageSender {
|
||||||
uuid,
|
uuid,
|
||||||
timestamps,
|
timestamps,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
e164?: string;
|
e164?: string;
|
||||||
uuid?: string;
|
uuid?: string;
|
||||||
timestamps: Array<number>;
|
timestamps: Array<number>;
|
||||||
options?: SendOptionsType;
|
options?: Readonly<SendOptionsType>;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
if (!uuid && !e164) {
|
if (!uuid && !e164) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'sendDeliveryReceipt: Neither uuid nor e164 was provided!'
|
'sendDeliveryReceipt: Neither uuid nor e164 was provided!'
|
||||||
|
@ -1553,12 +1563,12 @@ export default class MessageSender {
|
||||||
senderUuid,
|
senderUuid,
|
||||||
timestamps,
|
timestamps,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: Readonly<{
|
||||||
senderE164: string;
|
senderE164: string;
|
||||||
senderUuid: string;
|
senderUuid: string;
|
||||||
timestamps: Array<number>;
|
timestamps: Array<number>;
|
||||||
options?: SendOptionsType;
|
options?: Readonly<SendOptionsType>;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const receiptMessage = new Proto.ReceiptMessage();
|
const receiptMessage = new Proto.ReceiptMessage();
|
||||||
receiptMessage.type = Proto.ReceiptMessage.Type.READ;
|
receiptMessage.type = Proto.ReceiptMessage.Type.READ;
|
||||||
receiptMessage.timestamp = timestamps;
|
receiptMessage.timestamp = timestamps;
|
||||||
|
@ -1582,8 +1592,8 @@ export default class MessageSender {
|
||||||
uuid,
|
uuid,
|
||||||
e164,
|
e164,
|
||||||
padding,
|
padding,
|
||||||
}: { uuid?: string; e164?: string; padding?: Uint8Array },
|
}: Readonly<{ uuid?: string; e164?: string; padding?: Uint8Array }>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const nullMessage = new Proto.NullMessage();
|
const nullMessage = new Proto.NullMessage();
|
||||||
|
|
||||||
|
@ -1614,7 +1624,7 @@ export default class MessageSender {
|
||||||
uuid: string,
|
uuid: string,
|
||||||
e164: string,
|
e164: string,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
window.log.info('resetSession: start');
|
window.log.info('resetSession: start');
|
||||||
const proto = new Proto.DataMessage();
|
const proto = new Proto.DataMessage();
|
||||||
|
@ -1693,8 +1703,8 @@ export default class MessageSender {
|
||||||
identifier: string,
|
identifier: string,
|
||||||
expireTimer: number | undefined,
|
expireTimer: number | undefined,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
profileKey?: ArrayBuffer,
|
profileKey?: Readonly<ArrayBuffer>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
||||||
|
|
||||||
|
@ -1717,12 +1727,12 @@ export default class MessageSender {
|
||||||
options,
|
options,
|
||||||
plaintext,
|
plaintext,
|
||||||
uuid,
|
uuid,
|
||||||
}: {
|
}: Readonly<{
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
plaintext: PlaintextContent;
|
plaintext: PlaintextContent;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
||||||
|
|
||||||
return this.sendMessageProtoAndWait({
|
return this.sendMessageProtoAndWait({
|
||||||
|
@ -1746,13 +1756,13 @@ export default class MessageSender {
|
||||||
proto,
|
proto,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
}: {
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
messageId?: string;
|
messageId?: string;
|
||||||
proto: Buffer;
|
proto: Buffer;
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}): SendLogCallbackType {
|
}>): SendLogCallbackType {
|
||||||
let initialSavePromise: Promise<number>;
|
let initialSavePromise: Promise<number>;
|
||||||
|
|
||||||
return async ({
|
return async ({
|
||||||
|
@ -1814,15 +1824,15 @@ export default class MessageSender {
|
||||||
recipients,
|
recipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp = Date.now(),
|
timestamp = Date.now(),
|
||||||
}: {
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
proto: Proto.Content;
|
proto: Proto.Content;
|
||||||
recipients: Array<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const dataMessage = proto.dataMessage
|
const dataMessage = proto.dataMessage
|
||||||
? typedArrayToArrayBuffer(
|
? typedArrayToArrayBuffer(
|
||||||
Proto.DataMessage.encode(proto.dataMessage).finish()
|
Proto.DataMessage.encode(proto.dataMessage).finish()
|
||||||
|
@ -1902,13 +1912,13 @@ export default class MessageSender {
|
||||||
distributionId,
|
distributionId,
|
||||||
groupId,
|
groupId,
|
||||||
identifiers,
|
identifiers,
|
||||||
}: {
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
distributionId: string;
|
distributionId: string;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
identifiers: Array<string>;
|
identifiers: ReadonlyArray<string>;
|
||||||
},
|
}>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const contentMessage = new Proto.Content();
|
const contentMessage = new Proto.Content();
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
|
@ -1985,11 +1995,11 @@ export default class MessageSender {
|
||||||
|
|
||||||
async sendExpirationTimerUpdateToGroup(
|
async sendExpirationTimerUpdateToGroup(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
groupIdentifiers: Array<string>,
|
groupIdentifiers: ReadonlyArray<string>,
|
||||||
expireTimer: number | undefined,
|
expireTimer: number | undefined,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
profileKey?: ArrayBuffer,
|
profileKey?: Readonly<ArrayBuffer>,
|
||||||
options?: SendOptionsType
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
const myNumber = window.textsecure.storage.user.getNumber();
|
const myNumber = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid();
|
const myUuid = window.textsecure.storage.user.getUuid();
|
||||||
|
@ -2046,11 +2056,11 @@ export default class MessageSender {
|
||||||
|
|
||||||
async getProfile(
|
async getProfile(
|
||||||
number: string,
|
number: string,
|
||||||
options: {
|
options: Readonly<{
|
||||||
accessKey?: string;
|
accessKey?: string;
|
||||||
profileKeyVersion?: string;
|
profileKeyVersion?: string;
|
||||||
profileKeyCredentialRequest?: string;
|
profileKeyCredentialRequest?: string;
|
||||||
} = {}
|
}> = {}
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const { accessKey } = options;
|
const { accessKey } = options;
|
||||||
|
|
||||||
|
@ -2066,7 +2076,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUuidsForE164s(
|
async getUuidsForE164s(
|
||||||
numbers: Array<string>
|
numbers: ReadonlyArray<string>
|
||||||
): Promise<Dictionary<string | null>> {
|
): Promise<Dictionary<string | null>> {
|
||||||
return this.server.getUuidsForE164s(numbers);
|
return this.server.getUuidsForE164s(numbers);
|
||||||
}
|
}
|
||||||
|
@ -2084,33 +2094,35 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createGroup(
|
async createGroup(
|
||||||
group: Proto.IGroup,
|
group: Readonly<Proto.IGroup>,
|
||||||
options: GroupCredentialsType
|
options: Readonly<GroupCredentialsType>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.server.createGroup(group, options);
|
return this.server.createGroup(group, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadGroupAvatar(
|
async uploadGroupAvatar(
|
||||||
avatar: Uint8Array,
|
avatar: Readonly<Uint8Array>,
|
||||||
options: GroupCredentialsType
|
options: Readonly<GroupCredentialsType>
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return this.server.uploadGroupAvatar(avatar, options);
|
return this.server.uploadGroupAvatar(avatar, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroup(options: GroupCredentialsType): Promise<Proto.Group> {
|
async getGroup(
|
||||||
|
options: Readonly<GroupCredentialsType>
|
||||||
|
): Promise<Proto.Group> {
|
||||||
return this.server.getGroup(options);
|
return this.server.getGroup(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupFromLink(
|
async getGroupFromLink(
|
||||||
groupInviteLink: string,
|
groupInviteLink: string,
|
||||||
auth: GroupCredentialsType
|
auth: Readonly<GroupCredentialsType>
|
||||||
): Promise<Proto.GroupJoinInfo> {
|
): Promise<Proto.GroupJoinInfo> {
|
||||||
return this.server.getGroupFromLink(groupInviteLink, auth);
|
return this.server.getGroupFromLink(groupInviteLink, auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupLog(
|
async getGroupLog(
|
||||||
startVersion: number,
|
startVersion: number,
|
||||||
options: GroupCredentialsType
|
options: Readonly<GroupCredentialsType>
|
||||||
): Promise<GroupLogResponseType> {
|
): Promise<GroupLogResponseType> {
|
||||||
return this.server.getGroupLog(startVersion, options);
|
return this.server.getGroupLog(startVersion, options);
|
||||||
}
|
}
|
||||||
|
@ -2120,16 +2132,16 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async modifyGroup(
|
async modifyGroup(
|
||||||
changes: Proto.GroupChange.IActions,
|
changes: Readonly<Proto.GroupChange.IActions>,
|
||||||
options: GroupCredentialsType,
|
options: Readonly<GroupCredentialsType>,
|
||||||
inviteLinkBase64?: string
|
inviteLinkBase64?: string
|
||||||
): Promise<Proto.IGroupChange> {
|
): Promise<Proto.IGroupChange> {
|
||||||
return this.server.modifyGroup(changes, options, inviteLinkBase64);
|
return this.server.modifyGroup(changes, options, inviteLinkBase64);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendWithSenderKey(
|
async sendWithSenderKey(
|
||||||
data: ArrayBuffer,
|
data: Readonly<ArrayBuffer>,
|
||||||
accessKeys: ArrayBuffer,
|
accessKeys: Readonly<ArrayBuffer>,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean
|
online?: boolean
|
||||||
): Promise<MultiRecipient200ResponseType> {
|
): Promise<MultiRecipient200ResponseType> {
|
||||||
|
@ -2152,7 +2164,7 @@ export default class MessageSender {
|
||||||
|
|
||||||
async makeProxiedRequest(
|
async makeProxiedRequest(
|
||||||
url: string,
|
url: string,
|
||||||
options?: ProxiedRequestOptionsType
|
options?: Readonly<ProxiedRequestOptionsType>
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return this.server.makeProxiedRequest(url, options);
|
return this.server.makeProxiedRequest(url, options);
|
||||||
}
|
}
|
||||||
|
@ -2162,46 +2174,46 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStorageManifest(
|
async getStorageManifest(
|
||||||
options: StorageServiceCallOptionsType
|
options: Readonly<StorageServiceCallOptionsType>
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
return this.server.getStorageManifest(options);
|
return this.server.getStorageManifest(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStorageRecords(
|
async getStorageRecords(
|
||||||
data: ArrayBuffer,
|
data: Readonly<ArrayBuffer>,
|
||||||
options: StorageServiceCallOptionsType
|
options: Readonly<StorageServiceCallOptionsType>
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
return this.server.getStorageRecords(data, options);
|
return this.server.getStorageRecords(data, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async modifyStorageRecords(
|
async modifyStorageRecords(
|
||||||
data: ArrayBuffer,
|
data: Readonly<ArrayBuffer>,
|
||||||
options: StorageServiceCallOptionsType
|
options: Readonly<StorageServiceCallOptionsType>
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
return this.server.modifyStorageRecords(data, options);
|
return this.server.modifyStorageRecords(data, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMembershipToken(
|
async getGroupMembershipToken(
|
||||||
options: GroupCredentialsType
|
options: Readonly<GroupCredentialsType>
|
||||||
): Promise<Proto.GroupExternalCredential> {
|
): Promise<Proto.GroupExternalCredential> {
|
||||||
return this.server.getGroupExternalCredential(options);
|
return this.server.getGroupExternalCredential(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendChallengeResponse(
|
public async sendChallengeResponse(
|
||||||
challengeResponse: ChallengeType
|
challengeResponse: Readonly<ChallengeType>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.server.sendChallengeResponse(challengeResponse);
|
return this.server.sendChallengeResponse(challengeResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
async putProfile(
|
async putProfile(
|
||||||
jsonData: ProfileRequestDataType
|
jsonData: Readonly<ProfileRequestDataType>
|
||||||
): Promise<UploadAvatarHeadersType | undefined> {
|
): Promise<UploadAvatarHeadersType | undefined> {
|
||||||
return this.server.putProfile(jsonData);
|
return this.server.putProfile(jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadAvatar(
|
async uploadAvatar(
|
||||||
requestHeaders: UploadAvatarHeadersType,
|
requestHeaders: Readonly<UploadAvatarHeadersType>,
|
||||||
avatarData: ArrayBuffer
|
avatarData: Readonly<ArrayBuffer>
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return this.server.uploadAvatar(requestHeaders, avatarData);
|
return this.server.uploadAvatar(requestHeaders, avatarData);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue