mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Implement announcement groups
This commit is contained in:
parent
b745f1f902
commit
610e32aa52
5 changed files with 38 additions and 7 deletions
|
@ -809,7 +809,8 @@ public class Manager implements Closeable {
|
|||
GroupPermission addMemberPermission,
|
||||
GroupPermission editDetailsPermission,
|
||||
File avatarFile,
|
||||
Integer expirationTimer
|
||||
Integer expirationTimer,
|
||||
Boolean isAnnouncementGroup
|
||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, InvalidNumberException, NotAGroupMemberException {
|
||||
return updateGroup(groupId,
|
||||
name,
|
||||
|
@ -823,7 +824,8 @@ public class Manager implements Closeable {
|
|||
addMemberPermission,
|
||||
editDetailsPermission,
|
||||
avatarFile,
|
||||
expirationTimer);
|
||||
expirationTimer,
|
||||
isAnnouncementGroup);
|
||||
}
|
||||
|
||||
private Pair<Long, List<SendMessageResult>> updateGroup(
|
||||
|
@ -839,7 +841,8 @@ public class Manager implements Closeable {
|
|||
final GroupPermission addMemberPermission,
|
||||
final GroupPermission editDetailsPermission,
|
||||
final File avatarFile,
|
||||
final Integer expirationTimer
|
||||
final Integer expirationTimer,
|
||||
final Boolean isAnnouncementGroup
|
||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException {
|
||||
var group = getGroupForUpdating(groupId);
|
||||
|
||||
|
@ -857,7 +860,8 @@ public class Manager implements Closeable {
|
|||
addMemberPermission,
|
||||
editDetailsPermission,
|
||||
avatarFile,
|
||||
expirationTimer);
|
||||
expirationTimer,
|
||||
isAnnouncementGroup);
|
||||
} catch (ConflictException e) {
|
||||
// Detected conflicting update, refreshing group and trying again
|
||||
group = getGroup(groupId, true);
|
||||
|
@ -873,7 +877,8 @@ public class Manager implements Closeable {
|
|||
addMemberPermission,
|
||||
editDetailsPermission,
|
||||
avatarFile,
|
||||
expirationTimer);
|
||||
expirationTimer,
|
||||
isAnnouncementGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -948,7 +953,8 @@ public class Manager implements Closeable {
|
|||
final GroupPermission addMemberPermission,
|
||||
final GroupPermission editDetailsPermission,
|
||||
final File avatarFile,
|
||||
Integer expirationTimer
|
||||
final Integer expirationTimer,
|
||||
final Boolean isAnnouncementGroup
|
||||
) throws IOException {
|
||||
Pair<Long, List<SendMessageResult>> result = null;
|
||||
if (group.isPendingMember(account.getSelfRecipientId())) {
|
||||
|
@ -1034,6 +1040,11 @@ public class Manager implements Closeable {
|
|||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
||||
if (isAnnouncementGroup != null) {
|
||||
var groupGroupChangePair = groupV2Helper.setIsAnnouncementGroup(group, isAnnouncementGroup);
|
||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||
}
|
||||
|
||||
if (name != null || description != null || avatarFile != null) {
|
||||
var groupGroupChangePair = groupV2Helper.updateGroup(group, name, description, avatarFile);
|
||||
if (avatarFile != null) {
|
||||
|
|
|
@ -407,6 +407,14 @@ public class GroupV2Helper {
|
|||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
||||
public Pair<DecryptedGroup, GroupChange> setIsAnnouncementGroup(
|
||||
GroupInfoV2 groupInfoV2, boolean isAnnouncementGroup
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
final var change = groupOperations.createAnnouncementGroupChange(isAnnouncementGroup);
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
||||
private AccessControl.AccessRequired toAccessControl(final GroupLinkState state) {
|
||||
switch (state) {
|
||||
case DISABLED:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue