org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage Java Examples

The following examples show how to use org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) {
  Content.Builder             container      = Content.newBuilder();
  SyncMessage.Builder         syncMessage    = createSyncMessageBuilder();
  SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder();

  for (SignalServiceAddress address : blocked.getAddresses()) {
    if (address.getUuid().isPresent()) {
      blockedMessage.addUuids(address.getUuid().get().toString());
    }
    if (address.getNumber().isPresent()) {
      blockedMessage.addNumbers(address.getNumber().get());
    }
  }

  for (byte[] groupId : blocked.getGroupIds()) {
    blockedMessage.addGroupIds(ByteString.copyFrom(groupId));
  }

  return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray();
}
 
Example #2
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) {
  Content.Builder             container      = Content.newBuilder();
  SyncMessage.Builder         syncMessage    = createSyncMessageBuilder();
  SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder();

  for (SignalServiceAddress address : blocked.getAddresses()) {
    if (address.getUuid().isPresent()) {
      blockedMessage.addUuids(address.getUuid().get().toString());
    }
    if (address.getNumber().isPresent()) {
      blockedMessage.addNumbers(address.getNumber().get());
    }
  }

  for (byte[] groupId : blocked.getGroupIds()) {
    blockedMessage.addGroupIds(ByteString.copyFrom(groupId));
  }

  return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray();
}
 
Example #3
Source File: MultiDeviceBlockedUpdateJob.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRun()
    throws IOException, UntrustedIdentityException
{
  if (!TextSecurePreferences.isMultiDevice(context)) {
    Log.i(TAG, "Not multi device, aborting...");
    return;
  }

  RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);

  try (RecipientReader reader = database.readerForBlocked(database.getBlocked())) {
    List<SignalServiceAddress> blockedIndividuals = new LinkedList<>();
    List<byte[]>               blockedGroups      = new LinkedList<>();

    Recipient recipient;

    while ((recipient = reader.getNext()) != null) {
      if (recipient.isPushGroup()) {
        blockedGroups.add(recipient.requireGroupId().getDecodedId());
      } else if (recipient.hasServiceIdentifier()) {
        blockedIndividuals.add(RecipientUtil.toSignalServiceAddress(context, recipient));
      }
    }

    SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
    messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)),
                              UnidentifiedAccessUtil.getAccessForSync(context));
  }
}
 
Example #4
Source File: PushProcessMessageJob.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private void handleSynchronizeBlockedListMessage(@NonNull BlockedListMessage blockMessage) {
  DatabaseFactory.getRecipientDatabase(context).applyBlockedUpdate(blockMessage.getAddresses(), blockMessage.getGroupIds());
}