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
|
@ -38,11 +38,6 @@ export type SendMetadataType = {
|
|||
};
|
||||
};
|
||||
|
||||
type GroupMemberType = {
|
||||
uuid?: string;
|
||||
e164?: string;
|
||||
};
|
||||
|
||||
export type SendOptionsType = {
|
||||
senderCertificate?: ArrayBuffer;
|
||||
sendMetadata?: SendMetadataType;
|
||||
|
@ -1349,7 +1344,7 @@ export default class MessageSender {
|
|||
}
|
||||
|
||||
async createGroup(
|
||||
targetIdentifiers: Array<GroupMemberType>,
|
||||
targetIdentifiers: Array<string>,
|
||||
id: string,
|
||||
name: string,
|
||||
avatar: AttachmentType,
|
||||
|
@ -1360,7 +1355,7 @@ export default class MessageSender {
|
|||
proto.group.id = stringToArrayBuffer(id);
|
||||
|
||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||
proto.group.members = targetIdentifiers;
|
||||
proto.group.membersE164 = targetIdentifiers;
|
||||
proto.group.name = name;
|
||||
|
||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||
|
@ -1369,15 +1364,7 @@ export default class MessageSender {
|
|||
}
|
||||
proto.group.avatar = attachment;
|
||||
return this.sendGroupProto(
|
||||
targetIdentifiers.map(item => {
|
||||
const identifier = item.uuid || item.e164;
|
||||
if (!identifier) {
|
||||
throw new Error(
|
||||
'SendMessage.createGroup: Provided group member had neither uuid nor e164'
|
||||
);
|
||||
}
|
||||
return identifier;
|
||||
}),
|
||||
targetIdentifiers,
|
||||
proto,
|
||||
Date.now(),
|
||||
options
|
||||
|
@ -1395,7 +1382,7 @@ export default class MessageSender {
|
|||
groupId: string,
|
||||
name: string,
|
||||
avatar: AttachmentType,
|
||||
targetIdentifiers: Array<GroupMemberType>,
|
||||
targetIdentifiers: Array<string>,
|
||||
options?: SendOptionsType
|
||||
) {
|
||||
const proto = new window.textsecure.protobuf.DataMessage();
|
||||
|
@ -1404,7 +1391,7 @@ export default class MessageSender {
|
|||
proto.group.id = stringToArrayBuffer(groupId);
|
||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||
proto.group.name = name;
|
||||
proto.group.members = targetIdentifiers;
|
||||
proto.group.membersE164 = targetIdentifiers;
|
||||
|
||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||
if (!proto.group) {
|
||||
|
@ -1413,15 +1400,7 @@ export default class MessageSender {
|
|||
|
||||
proto.group.avatar = attachment;
|
||||
return this.sendGroupProto(
|
||||
targetIdentifiers.map(item => {
|
||||
const identifier = item.uuid || item.e164;
|
||||
if (!identifier) {
|
||||
throw new Error(
|
||||
'SendMessage.updateGroup: Provided group member had neither uuid nor e164'
|
||||
);
|
||||
}
|
||||
return identifier;
|
||||
}),
|
||||
targetIdentifiers,
|
||||
proto,
|
||||
Date.now(),
|
||||
options
|
||||
|
@ -1436,34 +1415,21 @@ export default class MessageSender {
|
|||
|
||||
async addIdentifierToGroup(
|
||||
groupId: string,
|
||||
newIdentifiers: Array<GroupMemberType>,
|
||||
newIdentifiers: Array<string>,
|
||||
options: SendOptionsType
|
||||
) {
|
||||
const proto = new window.textsecure.protobuf.DataMessage();
|
||||
proto.group = new window.textsecure.protobuf.GroupContext();
|
||||
proto.group.id = stringToArrayBuffer(groupId);
|
||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||
proto.group.members = newIdentifiers;
|
||||
return this.sendGroupProto(
|
||||
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
|
||||
);
|
||||
proto.group.membersE164 = newIdentifiers;
|
||||
return this.sendGroupProto(newIdentifiers, proto, Date.now(), options);
|
||||
}
|
||||
|
||||
async setGroupName(
|
||||
groupId: string,
|
||||
name: string,
|
||||
groupIdentifiers: Array<GroupMemberType>,
|
||||
groupIdentifiers: Array<string>,
|
||||
options: SendOptionsType
|
||||
) {
|
||||
const proto = new window.textsecure.protobuf.DataMessage();
|
||||
|
@ -1471,35 +1437,22 @@ export default class MessageSender {
|
|||
proto.group.id = stringToArrayBuffer(groupId);
|
||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||
proto.group.name = name;
|
||||
proto.group.members = groupIdentifiers;
|
||||
proto.group.membersE164 = groupIdentifiers;
|
||||
|
||||
return this.sendGroupProto(
|
||||
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
|
||||
);
|
||||
return this.sendGroupProto(groupIdentifiers, proto, Date.now(), options);
|
||||
}
|
||||
|
||||
async setGroupAvatar(
|
||||
groupId: string,
|
||||
avatar: AttachmentType,
|
||||
groupIdentifiers: Array<GroupMemberType>,
|
||||
groupIdentifiers: Array<string>,
|
||||
options: SendOptionsType
|
||||
) {
|
||||
const proto = new window.textsecure.protobuf.DataMessage();
|
||||
proto.group = new window.textsecure.protobuf.GroupContext();
|
||||
proto.group.id = stringToArrayBuffer(groupId);
|
||||
proto.group.type = window.textsecure.protobuf.GroupContext.Type.UPDATE;
|
||||
proto.group.members = groupIdentifiers;
|
||||
proto.group.membersE164 = groupIdentifiers;
|
||||
|
||||
return this.makeAttachmentPointer(avatar).then(async attachment => {
|
||||
if (!proto.group) {
|
||||
|
@ -1507,20 +1460,7 @@ export default class MessageSender {
|
|||
}
|
||||
|
||||
proto.group.avatar = attachment;
|
||||
return this.sendGroupProto(
|
||||
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
|
||||
);
|
||||
return this.sendGroupProto(groupIdentifiers, proto, Date.now(), options);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue