mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add group descriptions
This commit is contained in:
parent
8e8eed7b06
commit
dd0effc10c
8 changed files with 108 additions and 10 deletions
|
@ -783,17 +783,17 @@ public class Manager implements Closeable {
|
|||
}
|
||||
|
||||
public Pair<GroupId, List<SendMessageResult>> updateGroup(
|
||||
GroupId groupId, String name, List<String> members, File avatarFile
|
||||
GroupId groupId, String name, String description, List<String> members, File avatarFile
|
||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, InvalidNumberException, NotAGroupMemberException {
|
||||
final var membersRecipientIds = members == null ? null : getSignalServiceAddresses(members);
|
||||
if (membersRecipientIds != null) {
|
||||
membersRecipientIds.remove(account.getSelfRecipientId());
|
||||
}
|
||||
return sendUpdateGroupMessage(groupId, name, membersRecipientIds, avatarFile);
|
||||
return sendUpdateGroupMessage(groupId, name, description, membersRecipientIds, avatarFile);
|
||||
}
|
||||
|
||||
private Pair<GroupId, List<SendMessageResult>> sendUpdateGroupMessage(
|
||||
GroupId groupId, String name, Set<RecipientId> members, File avatarFile
|
||||
GroupId groupId, String name, String description, Set<RecipientId> members, File avatarFile
|
||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException {
|
||||
GroupInfo g;
|
||||
SignalServiceDataMessage.Builder messageBuilder;
|
||||
|
@ -809,6 +809,7 @@ public class Manager implements Closeable {
|
|||
messageBuilder = getGroupUpdateMessageBuilder(gv1);
|
||||
g = gv1;
|
||||
} else {
|
||||
// TODO set description as well
|
||||
final var gv2 = gv2Pair.first();
|
||||
final var decryptedGroup = gv2Pair.second();
|
||||
|
||||
|
@ -843,8 +844,8 @@ public class Manager implements Closeable {
|
|||
groupGroupChangePair.second());
|
||||
}
|
||||
}
|
||||
if (result == null || name != null || avatarFile != null) {
|
||||
var groupGroupChangePair = groupHelper.updateGroupV2(groupInfoV2, name, avatarFile);
|
||||
if (result == null || name != null || description != null || avatarFile != null) {
|
||||
var groupGroupChangePair = groupHelper.updateGroupV2(groupInfoV2, name, description, avatarFile);
|
||||
if (avatarFile != null) {
|
||||
avatarStore.storeGroupAvatar(groupInfoV2.getGroupId(),
|
||||
outputStream -> IOUtils.copyFileToStream(avatarFile, outputStream));
|
||||
|
|
|
@ -196,13 +196,17 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
public Pair<DecryptedGroup, GroupChange> updateGroupV2(
|
||||
GroupInfoV2 groupInfoV2, String name, File avatarFile
|
||||
GroupInfoV2 groupInfoV2, String name, String description, File avatarFile
|
||||
) throws IOException {
|
||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
||||
var groupOperations = groupsV2Operations.forGroup(groupSecretParams);
|
||||
|
||||
var change = name != null ? groupOperations.createModifyGroupTitle(name) : GroupChange.Actions.newBuilder();
|
||||
|
||||
if (description != null) {
|
||||
change.setModifyDescription(groupOperations.createModifyGroupDescription(description));
|
||||
}
|
||||
|
||||
if (avatarFile != null) {
|
||||
final var avatarBytes = readAvatarBytes(avatarFile);
|
||||
var avatarCdnKey = groupsV2Api.uploadAvatar(avatarBytes,
|
||||
|
|
|
@ -14,6 +14,10 @@ public abstract class GroupInfo {
|
|||
|
||||
public abstract String getTitle();
|
||||
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract GroupInviteLinkUrl getGroupInviteLink();
|
||||
|
||||
public abstract Set<RecipientId> getMembers();
|
||||
|
|
|
@ -59,6 +59,14 @@ public class GroupInfoV2 extends GroupInfo {
|
|||
return this.group.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
if (this.group == null) {
|
||||
return null;
|
||||
}
|
||||
return this.group.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupInviteLinkUrl getGroupInviteLink() {
|
||||
if (this.group == null || this.group.getInviteLinkPassword() == null || (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue