Add rudimentary ui for sending a group update

This commit is contained in:
lilia 2015-01-13 13:27:18 -10:00
parent 9e9a4c1de6
commit 44007ca58f
5 changed files with 142 additions and 1 deletions

View file

@ -339,6 +339,34 @@ window.textsecure.messaging = function() {
}
}
self.updateGroup = function(groupId, name, avatar, numbers) {
var proto = new textsecure.protobuf.PushMessageContent();
proto.group = new textsecure.protobuf.PushMessageContent.GroupContext();
proto.group.id = toArrayBuffer(groupId);
proto.group.type = textsecure.protobuf.PushMessageContent.GroupContext.Type.UPDATE;
proto.group.name = name;
var numbers = textsecure.storage.groups.addNumbers(groupId, numbers);
if (numbers === undefined) {
return new Promise(function(resolve, reject) { reject(new Error("Unknown Group")); });
}
proto.group.members = numbers;
if (avatar !== undefined) {
return makeAttachmentPointer(avatar).then(function(attachment) {
proto.group.avatar = attachment;
return sendGroupProto(numbers, proto).then(function() {
return proto.group.id;
});
});
} else {
return sendGroupProto(numbers, proto).then(function() {
return proto.group.id;
});
}
}
self.addNumberToGroup = function(groupId, number) {
var proto = new textsecure.protobuf.PushMessageContent();
proto.group = new textsecure.protobuf.PushMessageContent.GroupContext();