replace GroupUpdateV2 in proto to ClosedGroupControlMessage

pull/1465/head
Audric Ackermann 4 years ago
parent 79028ebaeb
commit 999e6fc712
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -144,7 +144,7 @@ message DataMessage {
optional string profilePicture = 2;
}
message ClosedGroupUpdateV2 {
message ClosedGroupControlMessage {
enum Type {
NEW = 1; // publicKey, name, encryptionKeyPair, members, admins
@ -194,7 +194,7 @@ message DataMessage {
repeated Preview preview = 10;
optional LokiProfile profile = 101;
optional GroupInvitation groupInvitation = 102;
optional ClosedGroupUpdateV2 closedGroupUpdateV2 = 104;
optional ClosedGroupControlMessage closedGroupControlMessage = 104;
}

@ -27,7 +27,7 @@ export async function handleClosedGroupV2(
groupUpdate: any
) {
const { type } = groupUpdate;
const { Type } = SignalService.DataMessage.ClosedGroupUpdateV2;
const { Type } = SignalService.DataMessage.ClosedGroupControlMessage;
if (BlockedNumberController.isGroupBlocked(PubKey.cast(envelope.source))) {
window.log.warn('Message ignored; destined for blocked group');
@ -47,7 +47,7 @@ export async function handleClosedGroupV2(
}
function sanityCheckNewGroupV2(
groupUpdate: SignalService.DataMessage.ClosedGroupUpdateV2
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
): boolean {
// for a new group message, we need everything to be set
const { name, publicKey, members, admins, encryptionKeyPair } = groupUpdate;
@ -111,12 +111,12 @@ function sanityCheckNewGroupV2(
async function handleNewClosedGroupV2(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupUpdateV2
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
const { log } = window;
if (
groupUpdate.type !== SignalService.DataMessage.ClosedGroupUpdateV2.Type.NEW
groupUpdate.type !== SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW
) {
return;
}
@ -217,11 +217,11 @@ async function handleNewClosedGroupV2(
async function handleUpdateClosedGroupV2(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupUpdateV2
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
if (
groupUpdate.type !==
SignalService.DataMessage.ClosedGroupUpdateV2.Type.UPDATE
SignalService.DataMessage.ClosedGroupControlMessage.Type.UPDATE
) {
return;
}
@ -342,11 +342,11 @@ async function handleUpdateClosedGroupV2(
*/
async function handleKeyPairClosedGroupV2(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupUpdateV2
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
if (
groupUpdate.type !==
SignalService.DataMessage.ClosedGroupUpdateV2.Type.ENCRYPTION_KEY_PAIR
SignalService.DataMessage.ClosedGroupControlMessage.Type.ENCRYPTION_KEY_PAIR
) {
return;
}
@ -412,9 +412,9 @@ async function handleKeyPairClosedGroupV2(
}
// Parse it
let proto: SignalService.DataMessage.ClosedGroupUpdateV2.KeyPair;
let proto: SignalService.DataMessage.ClosedGroupControlMessage.KeyPair;
try {
proto = SignalService.DataMessage.ClosedGroupUpdateV2.KeyPair.decode(
proto = SignalService.DataMessage.ClosedGroupControlMessage.KeyPair.decode(
plaintext
);
if (

@ -241,14 +241,9 @@ export function isMessageEmpty(message: SignalService.DataMessage) {
}
function isBodyEmpty(body: string) {
return _.isEmpty(body) || isBodyAutoFRContent(body);
return _.isEmpty(body);
}
function isBodyAutoFRContent(body: string) {
return (
body === 'Please accept to enable messages to be synced across devices'
);
}
export async function handleDataMessage(
envelope: EnvelopePlus,
@ -256,8 +251,8 @@ export async function handleDataMessage(
): Promise<void> {
window.log.info('data message from', getEnvelopeId(envelope));
if (dataMessage.closedGroupUpdateV2) {
await handleClosedGroupV2(envelope, dataMessage.closedGroupUpdateV2);
if (dataMessage.closedGroupControlMessage) {
await handleClosedGroupV2(envelope, dataMessage.closedGroupControlMessage);
return;
}

@ -478,11 +478,11 @@ export async function generateAndSendNewEncryptionKeyPair(
);
return;
}
const proto = new SignalService.DataMessage.ClosedGroupUpdateV2.KeyPair({
const proto = new SignalService.DataMessage.ClosedGroupControlMessage.KeyPair({
privateKey: newKeyPair?.privateKeyData,
publicKey: newKeyPair?.publicKeyData,
});
const plaintext = SignalService.DataMessage.ClosedGroupUpdateV2.KeyPair.encode(
const plaintext = SignalService.DataMessage.ClosedGroupControlMessage.KeyPair.encode(
proto
).finish();
@ -493,7 +493,7 @@ export async function generateAndSendNewEncryptionKeyPair(
PubKey.cast(pubkey),
plaintext
);
return new SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper({
return new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({
encryptedKeyPair: ciphertext,
publicKey: fromHexToArray(pubkey),
});

@ -8,13 +8,13 @@ import {
interface ClosedGroupV2EncryptionPairMessageParams
extends ClosedGroupV2MessageParams {
encryptedKeyPairs: Array<
SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>;
}
export class ClosedGroupV2EncryptionPairMessage extends ClosedGroupV2Message {
private readonly encryptedKeyPairs: Array<
SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>;
constructor(params: ClosedGroupV2EncryptionPairMessageParams) {
@ -34,9 +34,9 @@ export class ClosedGroupV2EncryptionPairMessage extends ClosedGroupV2Message {
const dataMessage = super.dataProto();
// tslint:disable: no-non-null-assertion
dataMessage.closedGroupUpdateV2!.type =
SignalService.DataMessage.ClosedGroupUpdateV2.Type.ENCRYPTION_KEY_PAIR;
dataMessage.closedGroupUpdateV2!.wrappers = this.encryptedKeyPairs.map(
dataMessage.closedGroupControlMessage!.type =
SignalService.DataMessage.ClosedGroupControlMessage.Type.ENCRYPTION_KEY_PAIR;
dataMessage.closedGroupControlMessage!.wrappers = this.encryptedKeyPairs.map(
w => {
const { publicKey, encryptedKeyPair } = w;
return {

@ -35,7 +35,7 @@ export abstract class ClosedGroupV2Message extends DataMessage {
public dataProto(): SignalService.DataMessage {
const dataMessage = new SignalService.DataMessage();
dataMessage.closedGroupUpdateV2 = new SignalService.DataMessage.ClosedGroupUpdateV2();
dataMessage.closedGroupControlMessage = new SignalService.DataMessage.ClosedGroupControlMessage();
dataMessage.expireTimer = this.expireTimer;
return dataMessage;

@ -58,23 +58,23 @@ export class ClosedGroupV2NewMessage extends ClosedGroupV2Message {
dataMessage.expireTimer = this.expireTimer;
dataMessage.closedGroupUpdateV2 = new SignalService.DataMessage.ClosedGroupUpdateV2();
dataMessage.closedGroupControlMessage = new SignalService.DataMessage.ClosedGroupControlMessage();
dataMessage.closedGroupUpdateV2.type =
SignalService.DataMessage.ClosedGroupUpdateV2.Type.NEW;
dataMessage.closedGroupUpdateV2.publicKey = fromHexToArray(
dataMessage.closedGroupControlMessage.type =
SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW;
dataMessage.closedGroupControlMessage.publicKey = fromHexToArray(
this.groupId.key
);
dataMessage.closedGroupUpdateV2.name = this.name;
dataMessage.closedGroupControlMessage.name = this.name;
dataMessage.closedGroupUpdateV2.admins = this.admins.map(fromHexToArray);
dataMessage.closedGroupUpdateV2.members = this.members.map(fromHexToArray);
dataMessage.closedGroupControlMessage.admins = this.admins.map(fromHexToArray);
dataMessage.closedGroupControlMessage.members = this.members.map(fromHexToArray);
try {
dataMessage.closedGroupUpdateV2.encryptionKeyPair = new SignalService.DataMessage.ClosedGroupUpdateV2.KeyPair();
dataMessage.closedGroupUpdateV2.encryptionKeyPair.privateKey = new Uint8Array(
dataMessage.closedGroupControlMessage.encryptionKeyPair = new SignalService.DataMessage.ClosedGroupControlMessage.KeyPair();
dataMessage.closedGroupControlMessage.encryptionKeyPair.privateKey = new Uint8Array(
this.keypair.privateKeyData
);
dataMessage.closedGroupUpdateV2.encryptionKeyPair.publicKey = new Uint8Array(
dataMessage.closedGroupControlMessage.encryptionKeyPair.publicKey = new Uint8Array(
this.keypair.publicKeyData
);
} catch (e) {

@ -38,11 +38,11 @@ export class ClosedGroupV2UpdateMessage extends ClosedGroupV2Message {
public dataProto(): SignalService.DataMessage {
const dataMessage = new SignalService.DataMessage();
dataMessage.closedGroupUpdateV2 = new SignalService.DataMessage.ClosedGroupUpdateV2();
dataMessage.closedGroupUpdateV2.type =
SignalService.DataMessage.ClosedGroupUpdateV2.Type.UPDATE;
dataMessage.closedGroupUpdateV2.name = this.name;
dataMessage.closedGroupUpdateV2.members = this.members.map(fromHexToArray);
dataMessage.closedGroupControlMessage = new SignalService.DataMessage.ClosedGroupControlMessage();
dataMessage.closedGroupControlMessage.type =
SignalService.DataMessage.ClosedGroupControlMessage.Type.UPDATE;
dataMessage.closedGroupControlMessage.name = this.name;
dataMessage.closedGroupControlMessage.members = this.members.map(fromHexToArray);
return dataMessage;
}

@ -134,10 +134,10 @@ describe('Message Utils', () => {
const device = TestUtils.generateFakePubKey();
const fakeWrappers = new Array<
SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>();
fakeWrappers.push(
new SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper({
new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({
publicKey: new Uint8Array(8),
encryptedKeyPair: new Uint8Array(8),
})
@ -156,10 +156,10 @@ describe('Message Utils', () => {
const device = TestUtils.generateFakePubKey();
const fakeWrappers = new Array<
SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>();
fakeWrappers.push(
new SignalService.DataMessage.ClosedGroupUpdateV2.KeyPairWrapper({
new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({
publicKey: new Uint8Array(8),
encryptedKeyPair: new Uint8Array(8),
})

Loading…
Cancel
Save