import org.asamk.signal.manager.api.SendGroupMessageResults;
import org.asamk.signal.manager.api.SendMessageResults;
import org.asamk.signal.manager.api.TypingAction;
+import org.asamk.signal.manager.api.UpdateGroup;
import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
-import org.asamk.signal.manager.groups.GroupLinkState;
import org.asamk.signal.manager.groups.GroupNotFoundException;
-import org.asamk.signal.manager.groups.GroupPermission;
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
import org.asamk.signal.manager.groups.LastGroupAdminException;
import org.asamk.signal.manager.groups.NotAGroupMemberException;
this.attachmentHelper = new AttachmentHelper(dependencies, attachmentStore);
this.pinHelper = new PinHelper(dependencies.getKeyBackupService());
- final var unidentifiedAccessHelper = new UnidentifiedAccessHelper(account::getProfileKey,
- account.getProfileStore()::getProfileKey,
- this::getRecipientProfile,
- this::getSenderCertificate);
+ final var unidentifiedAccessHelper = new UnidentifiedAccessHelper(account,
+ dependencies,
+ account::getProfileKey,
+ this::getRecipientProfile);
this.profileHelper = new ProfileHelper(account,
dependencies,
avatarStore,
- account.getProfileStore()::getProfileKey,
unidentifiedAccessHelper::getAccessFor,
this::resolveSignalServiceAddress);
final GroupV2Helper groupV2Helper = new GroupV2Helper(profileHelper::getRecipientProfileKeyCredential,
avatarStore,
this::resolveSignalServiceAddress,
account.getRecipientStore());
- this.storageHelper = new StorageHelper(account, dependencies, groupHelper);
+ this.storageHelper = new StorageHelper(account, dependencies, groupHelper, profileHelper);
this.contactHelper = new ContactHelper(account);
this.syncHelper = new SyncHelper(account,
attachmentHelper,
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
}
+
+ final var configurationStore = account.getConfigurationStore();
if (readReceipts != null) {
- account.getConfigurationStore().setReadReceipts(readReceipts);
+ configurationStore.setReadReceipts(readReceipts);
}
if (unidentifiedDeliveryIndicators != null) {
- account.getConfigurationStore().setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators);
+ configurationStore.setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators);
}
if (typingIndicators != null) {
- account.getConfigurationStore().setTypingIndicators(typingIndicators);
+ configurationStore.setTypingIndicators(typingIndicators);
}
if (linkPreviews != null) {
- account.getConfigurationStore().setLinkPreviews(linkPreviews);
+ configurationStore.setLinkPreviews(linkPreviews);
}
syncHelper.sendConfigurationMessage();
}
}
@Override
- public void removeLinkedDevices(int deviceId) throws IOException {
+ public void removeLinkedDevices(long deviceId) throws IOException {
dependencies.getAccountManager().removeDevice(deviceId);
var devices = dependencies.getAccountManager().getDevices();
account.setMultiDevice(devices.size() > 1);
.map(account.getRecipientStore()::resolveRecipientAddress)
.collect(Collectors.toSet()),
groupInfo.isBlocked(),
- groupInfo.getMessageExpirationTime(),
- groupInfo.isAnnouncementGroup(),
- groupInfo.isMember(account.getSelfRecipientId()));
+ groupInfo.getMessageExpirationTimer(),
+ groupInfo.getPermissionAddMember(),
+ groupInfo.getPermissionEditDetails(),
+ groupInfo.getPermissionSendMessage(),
+ groupInfo.isMember(account.getSelfRecipientId()),
+ groupInfo.isAdmin(account.getSelfRecipientId()));
}
@Override
@Override
public SendGroupMessageResults updateGroup(
- GroupId groupId,
- String name,
- String description,
- Set<RecipientIdentifier.Single> members,
- Set<RecipientIdentifier.Single> removeMembers,
- Set<RecipientIdentifier.Single> admins,
- Set<RecipientIdentifier.Single> removeAdmins,
- boolean resetGroupLink,
- GroupLinkState groupLinkState,
- GroupPermission addMemberPermission,
- GroupPermission editDetailsPermission,
- File avatarFile,
- Integer expirationTimer,
- Boolean isAnnouncementGroup
+ final GroupId groupId, final UpdateGroup updateGroup
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException {
return groupHelper.updateGroup(groupId,
- name,
- description,
- members == null ? null : resolveRecipients(members),
- removeMembers == null ? null : resolveRecipients(removeMembers),
- admins == null ? null : resolveRecipients(admins),
- removeAdmins == null ? null : resolveRecipients(removeAdmins),
- resetGroupLink,
- groupLinkState,
- addMemberPermission,
- editDetailsPermission,
- avatarFile,
- expirationTimer,
- isAnnouncementGroup);
+ updateGroup.getName(),
+ updateGroup.getDescription(),
+ updateGroup.getMembers() == null ? null : resolveRecipients(updateGroup.getMembers()),
+ updateGroup.getRemoveMembers() == null ? null : resolveRecipients(updateGroup.getRemoveMembers()),
+ updateGroup.getAdmins() == null ? null : resolveRecipients(updateGroup.getAdmins()),
+ updateGroup.getRemoveAdmins() == null ? null : resolveRecipients(updateGroup.getRemoveAdmins()),
+ updateGroup.isResetGroupLink(),
+ updateGroup.getGroupLinkState(),
+ updateGroup.getAddMemberPermission(),
+ updateGroup.getEditDetailsPermission(),
+ updateGroup.getAvatarFile(),
+ updateGroup.getExpirationTimer(),
+ updateGroup.getIsAnnouncementGroup());
}
@Override
@Override
public void setGroupBlocked(
final GroupId groupId, final boolean blocked
- ) throws GroupNotFoundException, IOException {
+ ) throws GroupNotFoundException, IOException, NotMasterDeviceException {
+ if (!account.isMasterDevice()) {
+ throw new NotMasterDeviceException();
+ }
groupHelper.setGroupBlocked(groupId, blocked);
// TODO cycle our profile key
syncHelper.sendBlockedList();
}
}
- private byte[] getSenderCertificate() {
- byte[] certificate;
- try {
- if (account.isPhoneNumberShared()) {
- certificate = dependencies.getAccountManager().getSenderCertificate();
- } else {
- certificate = dependencies.getAccountManager().getSenderCertificateForPhoneNumberPrivacy();
- }
- } catch (IOException e) {
- logger.warn("Failed to get sender certificate, ignoring: {}", e.getMessage());
- return null;
- }
- // TODO cache for a day
- return certificate;
- }
-
private RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException {
final var address = resolveSignalServiceAddress(recipientId);
if (!address.getNumber().isPresent()) {