Search in sources :

Example 1 with BlockedReader

use of org.thoughtcrime.securesms.database.RecipientDatabase.BlockedReader in project Signal-Android by signalapp.

the class MultiDeviceBlockedUpdateJob method onRun.

@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
    RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
    BlockedReader reader = database.readerForBlocked(database.getBlocked());
    List<String> blocked = new LinkedList<>();
    Recipient recipient;
    while ((recipient = reader.getNext()) != null) {
        if (!recipient.isGroupRecipient()) {
            blocked.add(recipient.getAddress().serialize());
        }
    }
    messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blocked)));
}
Also used : RecipientDatabase(org.thoughtcrime.securesms.database.RecipientDatabase) Recipient(org.thoughtcrime.securesms.recipients.Recipient) BlockedReader(org.thoughtcrime.securesms.database.RecipientDatabase.BlockedReader) BlockedListMessage(org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)1 BlockedReader (org.thoughtcrime.securesms.database.RecipientDatabase.BlockedReader)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1 BlockedListMessage (org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage)1