use of org.thoughtcrime.securesms.sms.IncomingJoinedMessage in project Signal-Android by signalapp.
the class DirectoryHelper method notifyNewUsers.
private static void notifyNewUsers(@NonNull Context context, @NonNull List<Address> newUsers) {
if (!TextSecurePreferences.isNewContactsNotificationEnabled(context))
return;
for (Address newUser : newUsers) {
if (!SessionUtil.hasSession(context, newUser) && !Util.isOwnNumber(context, newUser)) {
IncomingJoinedMessage message = new IncomingJoinedMessage(newUser);
Optional<InsertResult> insertResult = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);
if (insertResult.isPresent()) {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (hour >= 9 && hour < 23) {
MessageNotifier.updateNotification(context, insertResult.get().getThreadId(), true);
} else {
MessageNotifier.updateNotification(context, insertResult.get().getThreadId(), false);
}
}
}
}
}
use of org.thoughtcrime.securesms.sms.IncomingJoinedMessage in project Signal-Android by WhisperSystems.
the class DirectoryHelper method notifyNewUsers.
private static void notifyNewUsers(@NonNull Context context, @NonNull Collection<RecipientId> newUsers) {
if (!SignalStore.settings().isNotifyWhenContactJoinsSignal())
return;
for (RecipientId newUser : newUsers) {
Recipient recipient = Recipient.resolved(newUser);
if (!recipient.isSelf() && recipient.hasAUserSetDisplayName(context) && !hasSession(recipient.getId())) {
IncomingJoinedMessage message = new IncomingJoinedMessage(recipient.getId());
Optional<InsertResult> insertResult = SignalDatabase.sms().insertMessageInbox(message);
if (insertResult.isPresent()) {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (hour >= 9 && hour < 23) {
ApplicationDependencies.getMessageNotifier().updateNotification(context, insertResult.get().getThreadId(), true);
} else {
Log.i(TAG, "Not notifying of a new user due to the time of day. (Hour: " + hour + ")");
}
}
}
}
}
use of org.thoughtcrime.securesms.sms.IncomingJoinedMessage in project Signal-Android by WhisperSystems.
the class DirectoryHelper method notifyNewUsers.
private static void notifyNewUsers(@NonNull Context context, @Nullable MasterSecret masterSecret, @NonNull List<String> newUsers) {
if (!TextSecurePreferences.isNewContactsNotificationEnabled(context))
return;
for (String newUser : newUsers) {
if (!SessionUtil.hasSession(context, masterSecret, newUser) && !Util.isOwnNumber(context, newUser)) {
IncomingJoinedMessage message = new IncomingJoinedMessage(newUser);
Optional<InsertResult> insertResult = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);
if (insertResult.isPresent()) {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (hour >= 9 && hour < 23) {
MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), true);
} else {
MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), false);
}
}
}
}
}
Aggregations