Implement new dbus group interface

This commit is contained in:
AsamK 2021-10-07 21:18:14 +02:00
parent b5d4a5000b
commit 997b4f0c3f
15 changed files with 803 additions and 136 deletions

View file

@ -63,7 +63,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
resolveMembers(group.getPendingMembers()),
resolveMembers(group.getRequestingMembers()),
resolveMembers(group.getAdminMembers()),
group.getMessageExpirationTime() == 0 ? "disabled" : group.getMessageExpirationTime() + "s",
group.getMessageExpirationTimer() == 0 ? "disabled" : group.getMessageExpirationTimer() + "s",
groupInviteLink == null ? '-' : groupInviteLink.getUrl());
} else {
writer.println("Id: {} Name: {} Active: {} Blocked: {}",
@ -91,11 +91,14 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
group.getDescription(),
group.isMember(),
group.isBlocked(),
group.getMessageExpirationTime(),
group.getMessageExpirationTimer(),
resolveJsonMembers(group.getMembers()),
resolveJsonMembers(group.getPendingMembers()),
resolveJsonMembers(group.getRequestingMembers()),
resolveJsonMembers(group.getAdminMembers()),
group.getPermissionAddMember().name(),
group.getPermissionEditDetails().name(),
group.getPermissionSendMessage().name(),
groupInviteLink == null ? null : groupInviteLink.getUrl());
}).collect(Collectors.toList());
@ -122,6 +125,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
public final Set<JsonGroupMember> pendingMembers;
public final Set<JsonGroupMember> requestingMembers;
public final Set<JsonGroupMember> admins;
public final String permissionAddMember;
public final String permissionEditDetails;
public final String permissionSendMessage;
public final String groupInviteLink;
public JsonGroup(
@ -135,6 +141,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
Set<JsonGroupMember> pendingMembers,
Set<JsonGroupMember> requestingMembers,
Set<JsonGroupMember> admins,
final String permissionAddMember,
final String permissionEditDetails,
final String permissionSendMessage,
String groupInviteLink
) {
this.id = id;
@ -148,6 +157,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
this.pendingMembers = pendingMembers;
this.requestingMembers = requestingMembers;
this.admins = admins;
this.permissionAddMember = permissionAddMember;
this.permissionEditDetails = permissionEditDetails;
this.permissionSendMessage = permissionSendMessage;
this.groupInviteLink = groupInviteLink;
}
}

View file

@ -12,6 +12,7 @@ import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.AttachmentInvalidException;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.UpdateGroup;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupLinkState;
import org.asamk.signal.manager.groups.GroupNotFoundException;
@ -145,21 +146,23 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
}
var results = m.updateGroup(groupId,
groupName,
groupDescription,
groupMembers,
groupRemoveMembers,
groupAdmins,
groupRemoveAdmins,
groupResetLink,
groupLinkState,
groupAddMemberPermission,
groupEditDetailsPermission,
groupAvatar == null ? null : new File(groupAvatar),
groupExpiration,
groupSendMessagesPermission == null
? null
: groupSendMessagesPermission == GroupPermission.ONLY_ADMINS);
UpdateGroup.newBuilder()
.withName(groupName)
.withDescription(groupDescription)
.withMembers(groupMembers)
.withRemoveMembers(groupRemoveMembers)
.withAdmins(groupAdmins)
.withRemoveAdmins(groupRemoveAdmins)
.withResetGroupLink(groupResetLink)
.withGroupLinkState(groupLinkState)
.withAddMemberPermission(groupAddMemberPermission)
.withEditDetailsPermission(groupEditDetailsPermission)
.withAvatarFile(groupAvatar == null ? null : new File(groupAvatar))
.withExpirationTimer(groupExpiration)
.withIsAnnouncementGroup(groupSendMessagesPermission == null
? null
: groupSendMessagesPermission == GroupPermission.ONLY_ADMINS)
.build());
if (results != null) {
timestamp = results.getTimestamp();
ErrorUtils.handleSendMessageResults(results.getResults());