Only use membersE164 field in GroupV1 messages
This commit is contained in:
parent
bffbc1e5cf
commit
1518b159d3
7 changed files with 21 additions and 134 deletions
|
@ -2121,16 +2121,8 @@
|
||||||
'group'
|
'group'
|
||||||
);
|
);
|
||||||
|
|
||||||
const memberConversations = await Promise.all(
|
const memberConversations = details.membersE164.map(e164 =>
|
||||||
(details.members || details.membersE164).map(member => {
|
ConversationController.getOrCreate(e164, 'private')
|
||||||
if (member.e164 || member.uuid) {
|
|
||||||
return ConversationController.getOrCreateAndWait(
|
|
||||||
member.e164 || member.uuid,
|
|
||||||
'private'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ConversationController.getOrCreateAndWait(member, 'private');
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const members = memberConversations.map(c => c.get('id'));
|
const members = memberConversations.map(c => c.get('id'));
|
||||||
|
|
|
@ -2246,20 +2246,9 @@
|
||||||
if (dataMessage.group) {
|
if (dataMessage.group) {
|
||||||
const pendingGroupUpdate = [];
|
const pendingGroupUpdate = [];
|
||||||
const memberConversations = await Promise.all(
|
const memberConversations = await Promise.all(
|
||||||
(
|
dataMessage.group.membersE164.map(e164 =>
|
||||||
dataMessage.group.members || dataMessage.group.membersE164
|
ConversationController.getOrCreateAndWait(e164, 'private')
|
||||||
).map(member => {
|
)
|
||||||
if (member.e164 || member.uuid) {
|
|
||||||
return ConversationController.getOrCreateAndWait(
|
|
||||||
member.e164 || member.uuid,
|
|
||||||
'private'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ConversationController.getOrCreateAndWait(
|
|
||||||
member,
|
|
||||||
'private'
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
const members = memberConversations.map(c => c.get('id'));
|
const members = memberConversations.map(c => c.get('id'));
|
||||||
attributes = {
|
attributes = {
|
||||||
|
|
|
@ -64,12 +64,6 @@ describe('GroupBuffer', () => {
|
||||||
id: new Uint8Array([1, 3, 3, 7]).buffer,
|
id: new Uint8Array([1, 3, 3, 7]).buffer,
|
||||||
name: 'Hackers',
|
name: 'Hackers',
|
||||||
membersE164: ['cereal', 'burn', 'phreak', 'joey'],
|
membersE164: ['cereal', 'burn', 'phreak', 'joey'],
|
||||||
members: [
|
|
||||||
{ uuid: '3EA23646-92E8-4604-8833-6388861971C1', e164: 'cereal' },
|
|
||||||
{ uuid: 'B8414169-7149-4736-8E3B-477191931301', e164: 'burn' },
|
|
||||||
{ uuid: '64C97B95-A782-4E1E-BBCC-5A4ACE8d71f6', e164: 'phreak' },
|
|
||||||
{ uuid: 'CA334652-C35B-4FDC-9CC7-5F2060C771EE', e164: 'joey' },
|
|
||||||
],
|
|
||||||
avatar: { contentType: 'image/jpeg', length: avatarLen },
|
avatar: { contentType: 'image/jpeg', length: avatarLen },
|
||||||
});
|
});
|
||||||
const groupInfoBuffer = groupInfo.encode().toArrayBuffer();
|
const groupInfoBuffer = groupInfo.encode().toArrayBuffer();
|
||||||
|
@ -103,15 +97,6 @@ describe('GroupBuffer', () => {
|
||||||
'phreak',
|
'phreak',
|
||||||
'joey',
|
'joey',
|
||||||
]);
|
]);
|
||||||
assert.sameDeepMembers(
|
|
||||||
group.members.map(({ uuid, e164 }) => ({ uuid, e164 })),
|
|
||||||
[
|
|
||||||
{ uuid: '3ea23646-92e8-4604-8833-6388861971c1', e164: 'cereal' },
|
|
||||||
{ uuid: 'b8414169-7149-4736-8e3b-477191931301', e164: 'burn' },
|
|
||||||
{ uuid: '64c97b95-a782-4e1e-bbcc-5a4ace8d71f6', e164: 'phreak' },
|
|
||||||
{ uuid: 'ca334652-c35b-4fdc-9cc7-5f2060c771ee', e164: 'joey' },
|
|
||||||
]
|
|
||||||
);
|
|
||||||
assert.strictEqual(group.avatar.contentType, 'image/jpeg');
|
assert.strictEqual(group.avatar.contentType, 'image/jpeg');
|
||||||
assert.strictEqual(group.avatar.length, 255);
|
assert.strictEqual(group.avatar.length, 255);
|
||||||
assert.strictEqual(group.avatar.data.byteLength, 255);
|
assert.strictEqual(group.avatar.data.byteLength, 255);
|
||||||
|
|
|
@ -372,16 +372,11 @@ message GroupContext {
|
||||||
REQUEST_INFO = 4;
|
REQUEST_INFO = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Member {
|
|
||||||
optional string uuid = 1;
|
|
||||||
optional string e164 = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
optional bytes id = 1;
|
optional bytes id = 1;
|
||||||
optional Type type = 2;
|
optional Type type = 2;
|
||||||
optional string name = 3;
|
optional string name = 3;
|
||||||
repeated string membersE164 = 4;
|
repeated string membersE164 = 4;
|
||||||
repeated Member members = 6;
|
// field 6 was removed; do not use
|
||||||
optional AttachmentPointer avatar = 5;
|
optional AttachmentPointer avatar = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
ts/textsecure.d.ts
vendored
1
ts/textsecure.d.ts
vendored
|
@ -386,7 +386,6 @@ export declare class GroupContextClass {
|
||||||
type?: number;
|
type?: number;
|
||||||
name?: string | null;
|
name?: string | null;
|
||||||
membersE164?: Array<string>;
|
membersE164?: Array<string>;
|
||||||
members?: Array<GroupContextClass.Member>;
|
|
||||||
avatar?: AttachmentPointerClass | null;
|
avatar?: AttachmentPointerClass | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1696,7 +1696,6 @@ class MessageReceiverInner extends EventTarget {
|
||||||
case window.textsecure.protobuf.GroupContext.Type.DELIVER:
|
case window.textsecure.protobuf.GroupContext.Type.DELIVER:
|
||||||
decrypted.group.name = null;
|
decrypted.group.name = null;
|
||||||
decrypted.group.membersE164 = [];
|
decrypted.group.membersE164 = [];
|
||||||
decrypted.group.members = [];
|
|
||||||
decrypted.group.avatar = null;
|
decrypted.group.avatar = null;
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
@ -1798,18 +1797,6 @@ class MessageReceiverInner extends EventTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupMembers = decrypted.group ? decrypted.group.members || [] : [];
|
|
||||||
|
|
||||||
window.normalizeUuids(
|
|
||||||
decrypted,
|
|
||||||
[
|
|
||||||
'quote.authorUuid',
|
|
||||||
'reaction.targetAuthorUuid',
|
|
||||||
...groupMembers.map((_member, i) => `group.members.${i}.uuid`),
|
|
||||||
],
|
|
||||||
'message_receiver::processDecrypted'
|
|
||||||
);
|
|
||||||
|
|
||||||
return Promise.resolve(decrypted);
|
return Promise.resolve(decrypted);
|
||||||
/* eslint-enable no-bitwise, no-param-reassign */
|
/* eslint-enable no-bitwise, no-param-reassign */
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ export type SendMetadataType = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type GroupMemberType = {
|
|
||||||
uuid?: string;
|
|
||||||
e164?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SendOptionsType = {
|
export type SendOptionsType = {
|
||||||
senderCertificate?: ArrayBuffer;
|
senderCertificate?: ArrayBuffer;
|
||||||
sendMetadata?: SendMetadataType;
|
sendMetadata?: SendMetadataType;
|
||||||
|
@ -1349,7 +1344,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createGroup(
|
async createGroup(
|
||||||
targetIdentifiers: Array<GroupMemberType>,
|
targetIdentifiers: Array<string>,
|
||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
avatar: AttachmentType,
|
avatar: AttachmentType,
|
||||||
|
@ -1360,7 +1355,7 @@ export default class MessageSender {
|
||||||
proto.group.id = stringToArrayBuffer(id);
|
proto.group.id = stringToArrayBuffer(id);
|
||||||
|
|
||||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||||
proto.group.members = targetIdentifiers;
|
proto.group.membersE164 = targetIdentifiers;
|
||||||
proto.group.name = name;
|
proto.group.name = name;
|
||||||
|
|
||||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||||
|
@ -1369,15 +1364,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
proto.group.avatar = attachment;
|
proto.group.avatar = attachment;
|
||||||
return this.sendGroupProto(
|
return this.sendGroupProto(
|
||||||
targetIdentifiers.map(item => {
|
targetIdentifiers,
|
||||||
const identifier = item.uuid || item.e164;
|
|
||||||
if (!identifier) {
|
|
||||||
throw new Error(
|
|
||||||
'SendMessage.createGroup: Provided group member had neither uuid nor e164'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return identifier;
|
|
||||||
}),
|
|
||||||
proto,
|
proto,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
options
|
options
|
||||||
|
@ -1395,7 +1382,7 @@ export default class MessageSender {
|
||||||
groupId: string,
|
groupId: string,
|
||||||
name: string,
|
name: string,
|
||||||
avatar: AttachmentType,
|
avatar: AttachmentType,
|
||||||
targetIdentifiers: Array<GroupMemberType>,
|
targetIdentifiers: Array<string>,
|
||||||
options?: SendOptionsType
|
options?: SendOptionsType
|
||||||
) {
|
) {
|
||||||
const proto = new window.textsecure.protobuf.DataMessage();
|
const proto = new window.textsecure.protobuf.DataMessage();
|
||||||
|
@ -1404,7 +1391,7 @@ export default class MessageSender {
|
||||||
proto.group.id = stringToArrayBuffer(groupId);
|
proto.group.id = stringToArrayBuffer(groupId);
|
||||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||||
proto.group.name = name;
|
proto.group.name = name;
|
||||||
proto.group.members = targetIdentifiers;
|
proto.group.membersE164 = targetIdentifiers;
|
||||||
|
|
||||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||||
if (!proto.group) {
|
if (!proto.group) {
|
||||||
|
@ -1413,15 +1400,7 @@ export default class MessageSender {
|
||||||
|
|
||||||
proto.group.avatar = attachment;
|
proto.group.avatar = attachment;
|
||||||
return this.sendGroupProto(
|
return this.sendGroupProto(
|
||||||
targetIdentifiers.map(item => {
|
targetIdentifiers,
|
||||||
const identifier = item.uuid || item.e164;
|
|
||||||
if (!identifier) {
|
|
||||||
throw new Error(
|
|
||||||
'SendMessage.updateGroup: Provided group member had neither uuid nor e164'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return identifier;
|
|
||||||
}),
|
|
||||||
proto,
|
proto,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
options
|
options
|
||||||
|
@ -1436,34 +1415,21 @@ export default class MessageSender {
|
||||||
|
|
||||||
async addIdentifierToGroup(
|
async addIdentifierToGroup(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
newIdentifiers: Array<GroupMemberType>,
|
newIdentifiers: Array<string>,
|
||||||
options: SendOptionsType
|
options: SendOptionsType
|
||||||
) {
|
) {
|
||||||
const proto = new window.textsecure.protobuf.DataMessage();
|
const proto = new window.textsecure.protobuf.DataMessage();
|
||||||
proto.group = new window.textsecure.protobuf.GroupContext();
|
proto.group = new window.textsecure.protobuf.GroupContext();
|
||||||
proto.group.id = stringToArrayBuffer(groupId);
|
proto.group.id = stringToArrayBuffer(groupId);
|
||||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||||
proto.group.members = newIdentifiers;
|
proto.group.membersE164 = newIdentifiers;
|
||||||
return this.sendGroupProto(
|
return this.sendGroupProto(newIdentifiers, proto, Date.now(), options);
|
||||||
newIdentifiers.map(item => {
|
|
||||||
const identifier = item.uuid || item.e164;
|
|
||||||
if (!identifier) {
|
|
||||||
throw new Error(
|
|
||||||
'SendMessage.addIdentifierToGroup: Provided group member had neither uuid nor e164'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return identifier;
|
|
||||||
}),
|
|
||||||
proto,
|
|
||||||
Date.now(),
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupName(
|
async setGroupName(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
name: string,
|
name: string,
|
||||||
groupIdentifiers: Array<GroupMemberType>,
|
groupIdentifiers: Array<string>,
|
||||||
options: SendOptionsType
|
options: SendOptionsType
|
||||||
) {
|
) {
|
||||||
const proto = new window.textsecure.protobuf.DataMessage();
|
const proto = new window.textsecure.protobuf.DataMessage();
|
||||||
|
@ -1471,35 +1437,22 @@ export default class MessageSender {
|
||||||
proto.group.id = stringToArrayBuffer(groupId);
|
proto.group.id = stringToArrayBuffer(groupId);
|
||||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||||
proto.group.name = name;
|
proto.group.name = name;
|
||||||
proto.group.members = groupIdentifiers;
|
proto.group.membersE164 = groupIdentifiers;
|
||||||
|
|
||||||
return this.sendGroupProto(
|
return this.sendGroupProto(groupIdentifiers, proto, Date.now(), options);
|
||||||
groupIdentifiers.map(item => {
|
|
||||||
const identifier = item.uuid || item.e164;
|
|
||||||
if (!identifier) {
|
|
||||||
throw new Error(
|
|
||||||
'SendMessage.setGroupName: Provided group member had neither uuid nor e164'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return identifier;
|
|
||||||
}),
|
|
||||||
proto,
|
|
||||||
Date.now(),
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupAvatar(
|
async setGroupAvatar(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
avatar: AttachmentType,
|
avatar: AttachmentType,
|
||||||
groupIdentifiers: Array<GroupMemberType>,
|
groupIdentifiers: Array<string>,
|
||||||
options: SendOptionsType
|
options: SendOptionsType
|
||||||
) {
|
) {
|
||||||
const proto = new window.textsecure.protobuf.DataMessage();
|
const proto = new window.textsecure.protobuf.DataMessage();
|
||||||
proto.group = new window.textsecure.protobuf.GroupContext();
|
proto.group = new window.textsecure.protobuf.GroupContext();
|
||||||
proto.group.id = stringToArrayBuffer(groupId);
|
proto.group.id = stringToArrayBuffer(groupId);
|
||||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||||
proto.group.members = groupIdentifiers;
|
proto.group.membersE164 = groupIdentifiers;
|
||||||
|
|
||||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||||
if (!proto.group) {
|
if (!proto.group) {
|
||||||
|
@ -1507,20 +1460,7 @@ export default class MessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.group.avatar = attachment;
|
proto.group.avatar = attachment;
|
||||||
return this.sendGroupProto(
|
return this.sendGroupProto(groupIdentifiers, proto, Date.now(), options);
|
||||||
groupIdentifiers.map(item => {
|
|
||||||
const identifier = item.uuid || item.e164;
|
|
||||||
if (!identifier) {
|
|
||||||
throw new Error(
|
|
||||||
'SendMessage.setGroupAvatar: Provided group member had neither uuid nor e164'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return identifier;
|
|
||||||
}),
|
|
||||||
proto,
|
|
||||||
Date.now(),
|
|
||||||
options
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue