mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-25 10:04:23 +01:00
Split createGroup out of updateGroup method
This commit is contained in:
@@ -62,15 +62,20 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
|
||||
var groupAvatar = ns.getString("avatar");
|
||||
|
||||
try {
|
||||
var results = m.updateGroup(groupId,
|
||||
groupName,
|
||||
groupDescription,
|
||||
groupMembers,
|
||||
groupAvatar == null ? null : new File(groupAvatar));
|
||||
ErrorUtils.handleTimestampAndSendMessageResults(writer, 0, results.second());
|
||||
final var newGroupId = results.first();
|
||||
if (groupId == null) {
|
||||
var results = m.createGroup(groupName,
|
||||
groupMembers,
|
||||
groupAvatar == null ? null : new File(groupAvatar));
|
||||
ErrorUtils.handleTimestampAndSendMessageResults(writer, 0, results.second());
|
||||
final var newGroupId = results.first();
|
||||
writer.println("Created new group: \"{}\"", newGroupId.toBase64());
|
||||
} else {
|
||||
var results = m.updateGroup(groupId,
|
||||
groupName,
|
||||
groupDescription,
|
||||
groupMembers,
|
||||
groupAvatar == null ? null : new File(groupAvatar));
|
||||
ErrorUtils.handleTimestampAndSendMessageResults(writer, results.first(), results.second());
|
||||
}
|
||||
} catch (AttachmentInvalidException e) {
|
||||
throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
|
||||
|
||||
@@ -335,13 +335,19 @@ public class DbusSignalImpl implements Signal {
|
||||
if (avatar.isEmpty()) {
|
||||
avatar = null;
|
||||
}
|
||||
final var results = m.updateGroup(groupId == null ? null : GroupId.unknownVersion(groupId),
|
||||
name,
|
||||
null,
|
||||
members,
|
||||
avatar == null ? null : new File(avatar));
|
||||
checkSendMessageResults(0, results.second());
|
||||
return results.first().serialize();
|
||||
if (groupId == null) {
|
||||
final var results = m.createGroup(name, members, avatar == null ? null : new File(avatar));
|
||||
checkSendMessageResults(0, results.second());
|
||||
return results.first().serialize();
|
||||
} else {
|
||||
final var results = m.updateGroup(GroupId.unknownVersion(groupId),
|
||||
name,
|
||||
null,
|
||||
members,
|
||||
avatar == null ? null : new File(avatar));
|
||||
checkSendMessageResults(results.first(), results.second());
|
||||
return groupId;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException e) {
|
||||
|
||||
Reference in New Issue
Block a user