]> nmode's Git Repositories - signal-cli/commitdiff
Extract getSelfProfile method
authorAsamK <asamk@gmx.de>
Sat, 14 May 2022 13:19:00 +0000 (15:19 +0200)
committerAsamK <asamk@gmx.de>
Sat, 14 May 2022 13:51:23 +0000 (15:51 +0200)
lib/src/main/java/org/asamk/signal/manager/helper/IncomingMessageHandler.java
lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java
lib/src/main/java/org/asamk/signal/manager/helper/SendHelper.java
lib/src/main/java/org/asamk/signal/manager/helper/UnidentifiedAccessHelper.java

index c4b1524cf7042c95bb773920e52fafdf1811f4ae..489be8346b24a86af6e45c3e87124d65da8e5ba4 100644 (file)
@@ -130,8 +130,7 @@ public final class IncomingMessageHandler {
                     logger.debug("Received invalid message from blocked contact, ignoring.");
                 } else {
                     final var senderProfile = context.getProfileHelper().getRecipientProfile(sender);
-                    final var selfProfile = context.getProfileHelper()
-                            .getRecipientProfile(account.getSelfRecipientId());
+                    final var selfProfile = context.getProfileHelper().getSelfProfile();
                     if ((!sender.equals(account.getSelfRecipientId()) || e.getSenderDevice() != account.getDeviceId())
                             && senderProfile != null
                             && senderProfile.getCapabilities().contains(Profile.Capability.senderKey)
index 53a48466e1120b477fcb59bc7ce73188a004e0b3..7afa63fcd4aa2c26f6befd93fb127128b9276be5 100644 (file)
@@ -114,7 +114,7 @@ public final class ProfileHelper {
             String aboutEmoji,
             Optional<File> avatar
     ) throws IOException {
-        var profile = getRecipientProfile(account.getSelfRecipientId());
+        var profile = getSelfProfile();
         var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
         if (givenName != null) {
             builder.withGivenName(givenName);
@@ -164,6 +164,10 @@ public final class ProfileHelper {
         account.getProfileStore().storeProfile(account.getSelfRecipientId(), newProfile);
     }
 
+    public Profile getSelfProfile() {
+        return getRecipientProfile(account.getSelfRecipientId());
+    }
+
     public List<Profile> getRecipientProfile(List<RecipientId> recipientIds) {
         try {
             account.getRecipientStore().setBulkUpdating(true);
index 652c46943cf72aaac5f60978bd023e03b03cb5b3..0797f84ca1be0d4fd6b26a43ee844d9321e244da 100644 (file)
@@ -441,7 +441,7 @@ public class SendHelper {
     }
 
     private Set<RecipientId> getSenderKeyCapableRecipientIds(final Set<RecipientId> recipientIds) {
-        final var selfProfile = context.getProfileHelper().getRecipientProfile(account.getSelfRecipientId());
+        final var selfProfile = context.getProfileHelper().getSelfProfile();
         if (selfProfile == null || !selfProfile.getCapabilities().contains(Profile.Capability.senderKey)) {
             logger.debug("Not all of our devices support sender key. Using legacy.");
             return Set.of();
index 7dd412a46c96fa1130a0027b9dd3f50d2fa8e222..bdd6221b6a3abf96ba67fd28c994f373ac102a85 100644 (file)
@@ -143,7 +143,7 @@ public class UnidentifiedAccessHelper {
     private byte[] getSelfUnidentifiedAccessKey(boolean noRefresh) {
         var selfProfile = noRefresh
                 ? account.getProfileStore().getProfile(account.getSelfRecipientId())
-                : context.getProfileHelper().getRecipientProfile(account.getSelfRecipientId());
+                : context.getProfileHelper().getSelfProfile();
         if (selfProfile != null
                 && selfProfile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED) {
             return createUnrestrictedUnidentifiedAccess();