From cdeac8f424c3e49071035afef0391e127c272822 Mon Sep 17 00:00:00 2001 From: warrickct Date: Fri, 4 Feb 2022 13:43:04 +1100 Subject: [PATCH] Adding protobuf changes for message request response. --- protos/SignalService.proto | 8 +++++ .../controlMessage/MessageRequestResponse.ts | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 ts/session/messages/outgoing/controlMessage/MessageRequestResponse.ts diff --git a/protos/SignalService.proto b/protos/SignalService.proto index a71bde61b..4fb3db885 100644 --- a/protos/SignalService.proto +++ b/protos/SignalService.proto @@ -35,6 +35,12 @@ message Unsend { required string author = 2; } +message MessageRequestResponse { + // @required + required bytes publicKey = 1; // The public key of the contact that was approved + // @required + required bool isApproved = 2; +} message Content { optional DataMessage dataMessage = 1; @@ -44,6 +50,7 @@ message Content { optional ConfigurationMessage configurationMessage = 7; optional DataExtractionNotification dataExtractionNotification = 8; optional Unsend unsendMessage = 9; + optional MessageRequestResponse messageRequestResponse = 10; } message KeyPair { @@ -195,6 +202,7 @@ message ConfigurationMessage { optional bytes profileKey = 4; optional bool isApproved = 5; optional bool isBlocked = 6; + optional bool didApproveMe = 7; } repeated ClosedGroup closedGroups = 1; diff --git a/ts/session/messages/outgoing/controlMessage/MessageRequestResponse.ts b/ts/session/messages/outgoing/controlMessage/MessageRequestResponse.ts new file mode 100644 index 000000000..be8192a2b --- /dev/null +++ b/ts/session/messages/outgoing/controlMessage/MessageRequestResponse.ts @@ -0,0 +1,36 @@ +import { SignalService } from '../../../../protobuf'; +import { ContentMessage } from '../ContentMessage'; +import { MessageParams } from '../Message'; + +interface MessageRequestResponseParams extends MessageParams { + publicKey: Uint8Array; + isApproved: boolean; +} + +export class MessageRequestResponse extends ContentMessage { + private readonly publicKey: Uint8Array; + private readonly isApproved: boolean; + + constructor(params: MessageRequestResponseParams) { + super({ + timestamp: params.timestamp, + publicKey: params.publicKey, + isApproved: params.isApproved, + } as MessageRequestResponseParams); + this.publicKey = params.publicKey; + this.isApproved = params.isApproved; + } + + public contentProto(): SignalService.Content { + return new SignalService.Content({ + messageRequestResponse: this.messageRequestResponseProto(), + }); + } + + public messageRequestResponseProto(): SignalService.MessageRequestResponse { + return new SignalService.MessageRequestResponse({ + publicKey: this.publicKey, + isApproved: this.isApproved, + }); + } +}