Added support for group request info

pull/877/head
Mikunj 5 years ago
parent d20d31b574
commit fc6ca57e1e

@ -787,6 +787,7 @@
'group' 'group'
); );
convo.updateGroupAdmins([primaryDeviceKey]);
convo.updateGroup(ev.groupDetails); convo.updateGroup(ev.groupDetails);
// Group conversations are automatically 'friends' // Group conversations are automatically 'friends'
@ -795,8 +796,6 @@
window.friends.friendRequestStatusEnum.friends window.friends.friendRequestStatusEnum.friends
); );
convo.updateGroupAdmins([primaryDeviceKey]);
appView.openConversation(groupId, {}); appView.openConversation(groupId, {});
}; };

@ -2232,6 +2232,7 @@
this.get('name'), this.get('name'),
this.get('avatar'), this.get('avatar'),
this.get('members'), this.get('members'),
this.get('groupAdmins'),
groupUpdate.recipients, groupUpdate.recipients,
options options
) )
@ -2239,6 +2240,21 @@
); );
}, },
sendGroupInfo(recipients) {
if (this.isClosedGroup()) {
const options = this.getSendOptions();
textsecure.messaging.updateGroup(
this.id,
this.get('name'),
this.get('avatar'),
this.get('members'),
this.get('groupAdmins'),
recipients,
options
);
}
},
async leaveGroup() { async leaveGroup() {
const now = Date.now(); const now = Date.now();
if (this.get('type') === 'group') { if (this.get('type') === 'group') {
@ -2323,6 +2339,7 @@
const ourNumber = textsecure.storage.user.getNumber(); const ourNumber = textsecure.storage.user.getNumber();
return !stillUnread.some( return !stillUnread.some(
m => m =>
m.propsForMessage &&
m.propsForMessage.text && m.propsForMessage.text &&
m.propsForMessage.text.indexOf(`@${ourNumber}`) !== -1 m.propsForMessage.text.indexOf(`@${ourNumber}`) !== -1
); );

@ -1929,8 +1929,14 @@
} }
} }
if (initialMessage.group) {
if ( if (
initialMessage.group && initialMessage.group.type === GROUP_TYPES.REQUEST_INFO &&
!newGroup
) {
conversation.sendGroupInfo([source]);
return null;
} else if (
initialMessage.group.members && initialMessage.group.members &&
initialMessage.group.type === GROUP_TYPES.UPDATE initialMessage.group.type === GROUP_TYPES.UPDATE
) { ) {
@ -2001,6 +2007,12 @@
}); });
} }
}); });
} else if (newGroup) {
// We have an unknown group, we should request info
textsecure.messaging.requestGroupInfo(conversationId, [
primarySource,
]);
}
} }
const isSessionRequest = const isSessionRequest =

@ -1786,6 +1786,10 @@ MessageReceiver.prototype.extend({
decrypted.group.members = []; decrypted.group.members = [];
decrypted.group.avatar = null; decrypted.group.avatar = null;
break; break;
case textsecure.protobuf.GroupContext.Type.REQUEST_INFO:
decrypted.body = null;
decrypted.attachments = [];
break;
default: default:
this.removeFromCache(envelope); this.removeFromCache(envelope);
throw new Error('Unknown group message type'); throw new Error('Unknown group message type');

@ -1107,7 +1107,7 @@ MessageSender.prototype = {
return this.sendMessage(attrs, options); return this.sendMessage(attrs, options);
}, },
updateGroup(groupId, name, avatar, members, recipients, options) { updateGroup(groupId, name, avatar, members, admins, recipients, options) {
const proto = new textsecure.protobuf.DataMessage(); const proto = new textsecure.protobuf.DataMessage();
proto.group = new textsecure.protobuf.GroupContext(); proto.group = new textsecure.protobuf.GroupContext();
@ -1164,6 +1164,14 @@ MessageSender.prototype = {
}); });
}, },
requestGroupInfo(groupId, groupNumbers, options) {
const proto = new textsecure.protobuf.DataMessage();
proto.group = new textsecure.protobuf.GroupContext();
proto.group.id = stringToArrayBuffer(groupId);
proto.group.type = textsecure.protobuf.GroupContext.Type.REQUEST_INFO;
return this.sendGroupProto(groupNumbers, proto, Date.now(), options);
},
leaveGroup(groupId, groupNumbers, options) { leaveGroup(groupId, groupNumbers, options) {
const proto = new textsecure.protobuf.DataMessage(); const proto = new textsecure.protobuf.DataMessage();
proto.group = new textsecure.protobuf.GroupContext(); proto.group = new textsecure.protobuf.GroupContext();
@ -1263,6 +1271,7 @@ textsecure.MessageSender = function MessageSenderWrapper(username, password) {
this.addNumberToGroup = sender.addNumberToGroup.bind(sender); this.addNumberToGroup = sender.addNumberToGroup.bind(sender);
this.setGroupName = sender.setGroupName.bind(sender); this.setGroupName = sender.setGroupName.bind(sender);
this.setGroupAvatar = sender.setGroupAvatar.bind(sender); this.setGroupAvatar = sender.setGroupAvatar.bind(sender);
this.requestGroupInfo = sender.requestGroupInfo.bind(sender);
this.leaveGroup = sender.leaveGroup.bind(sender); this.leaveGroup = sender.leaveGroup.bind(sender);
this.sendSyncMessage = sender.sendSyncMessage.bind(sender); this.sendSyncMessage = sender.sendSyncMessage.bind(sender);
this.getProfile = sender.getProfile.bind(sender); this.getProfile = sender.getProfile.bind(sender);

Loading…
Cancel
Save