@Ignore @Test public void givenSecureMessagesSent_whenIShareProfileIfFirstSecureMessage_thenIShareProfile() { when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(anyLong())).thenReturn(5); RecipientUtil.shareProfileIfFirstSecureMessage(context, recipient); verify(mockRecipientDatabase, never()).setProfileSharing(recipient.getId(), true); }
@WorkerThread public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) { long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(recipient.getId()); if (isPreMessageRequestThread(context, threadId)) { return; } boolean firstMessage = DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) == 0; if (firstMessage) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true); } }
RecipientUtil { @WorkerThread public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) { long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(recipient.getId()); if (isPreMessageRequestThread(context, threadId)) { return; } boolean firstMessage = DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) == 0; if (firstMessage) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true); } } }
RecipientUtil { @WorkerThread public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) { long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(recipient.getId()); if (isPreMessageRequestThread(context, threadId)) { return; } boolean firstMessage = DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) == 0; if (firstMessage) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true); } }  }
RecipientUtil { @WorkerThread public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) { long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(recipient.getId()); if (isPreMessageRequestThread(context, threadId)) { return; } boolean firstMessage = DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) == 0; if (firstMessage) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true); } }  @WorkerThread static @NonNull SignalServiceAddress toSignalServiceAddressBestEffort(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static @NonNull SignalServiceAddress toSignalServiceAddress(@NonNull Context context, @NonNull Recipient recipient); static @NonNull List<SignalServiceAddress> toSignalServiceAddresses(@NonNull Context context, @NonNull List<RecipientId> recipients); static @NonNull List<SignalServiceAddress> toSignalServiceAddressesFromResolved(@NonNull Context context, @NonNull List<Recipient> recipients); static void ensureUuidsAreAvailable(@NonNull Context context, @NonNull Collection<Recipient> recipients); static boolean isBlockable(@NonNull Recipient recipient); static List<Recipient> getEligibleForSending(@NonNull List<Recipient> recipients); @WorkerThread static void blockNonGroup(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static void block(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static void unblock(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static boolean isMessageRequestAccepted(@NonNull Context context, long threadId); @WorkerThread static boolean isMessageRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient); @WorkerThread static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient); @WorkerThread static boolean isPreMessageRequestThread(@NonNull Context context, long threadId); @WorkerThread static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient); static boolean isLegacyProfileSharingAccepted(@NonNull Recipient threadRecipient); }
RecipientUtil { @WorkerThread public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) { long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(recipient.getId()); if (isPreMessageRequestThread(context, threadId)) { return; } boolean firstMessage = DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) == 0; if (firstMessage) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true); } }  @WorkerThread static @NonNull SignalServiceAddress toSignalServiceAddressBestEffort(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static @NonNull SignalServiceAddress toSignalServiceAddress(@NonNull Context context, @NonNull Recipient recipient); static @NonNull List<SignalServiceAddress> toSignalServiceAddresses(@NonNull Context context, @NonNull List<RecipientId> recipients); static @NonNull List<SignalServiceAddress> toSignalServiceAddressesFromResolved(@NonNull Context context, @NonNull List<Recipient> recipients); static void ensureUuidsAreAvailable(@NonNull Context context, @NonNull Collection<Recipient> recipients); static boolean isBlockable(@NonNull Recipient recipient); static List<Recipient> getEligibleForSending(@NonNull List<Recipient> recipients); @WorkerThread static void blockNonGroup(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static void block(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static void unblock(@NonNull Context context, @NonNull Recipient recipient); @WorkerThread static boolean isMessageRequestAccepted(@NonNull Context context, long threadId); @WorkerThread static boolean isMessageRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient); @WorkerThread static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient); @WorkerThread static boolean isPreMessageRequestThread(@NonNull Context context, long threadId); @WorkerThread static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient); static boolean isLegacyProfileSharingAccepted(@NonNull Recipient threadRecipient);  }