use of org.thoughtcrime.securesms.net.NotPushRegisteredException in project Signal-Android by WhisperSystems.
the class MultiDeviceBlockedUpdateJob method onRun.
@Override
public void onRun() throws IOException, UntrustedIdentityException {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
RecipientDatabase database = SignalDatabase.recipients();
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.isMaybeRegistered() && (recipient.hasServiceId() || recipient.hasE164())) {
blockedIndividuals.add(RecipientUtil.toSignalServiceAddress(context, recipient));
}
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)), UnidentifiedAccessUtil.getAccessForSync(context));
}
}
use of org.thoughtcrime.securesms.net.NotPushRegisteredException in project Signal-Android by WhisperSystems.
the class ReactionSendJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
ReactionDatabase reactionDatabase = SignalDatabase.reactions();
MessageRecord message;
if (messageId.isMms()) {
message = SignalDatabase.mms().getMessageRecord(messageId.getId());
} else {
message = SignalDatabase.sms().getSmsMessage(messageId.getId());
}
Recipient targetAuthor = message.isOutgoing() ? Recipient.self() : message.getIndividualRecipient();
long targetSentTimestamp = message.getDateSent();
if (targetAuthor.getId().equals(SignalStore.releaseChannelValues().getReleaseChannelRecipientId())) {
return;
}
if (!remove && !reactionDatabase.hasReaction(messageId, reaction)) {
Log.w(TAG, "Went to add a reaction, but it's no longer present on the message!");
return;
}
if (remove && reactionDatabase.hasReaction(messageId, reaction)) {
Log.w(TAG, "Went to remove a reaction, but it's still there!");
return;
}
Recipient conversationRecipient = SignalDatabase.threads().getRecipientForThreadId(message.getThreadId());
if (conversationRecipient == null) {
throw new AssertionError("We have a message, but couldn't find the thread!");
}
if (conversationRecipient.isPushV1Group() || conversationRecipient.isMmsGroup()) {
Log.w(TAG, "Cannot send reactions to legacy groups.");
return;
}
List<Recipient> resolved = recipients.stream().map(Recipient::resolved).collect(Collectors.toList());
List<RecipientId> unregistered = resolved.stream().filter(Recipient::isUnregistered).map(Recipient::getId).collect(Collectors.toList());
List<Recipient> destinations = resolved.stream().filter(Recipient::isMaybeRegistered).collect(Collectors.toList());
List<Recipient> completions = deliver(conversationRecipient, destinations, targetAuthor, targetSentTimestamp);
recipients.removeAll(unregistered);
recipients.removeAll(completions.stream().map(Recipient::getId).collect(Collectors.toList()));
Log.i(TAG, "Completed now: " + completions.size() + ", Remaining: " + recipients.size());
if (!recipients.isEmpty()) {
Log.w(TAG, "Still need to send to " + recipients.size() + " recipients. Retrying.");
throw new RetryLaterException();
}
}
use of org.thoughtcrime.securesms.net.NotPushRegisteredException in project Signal-Android by WhisperSystems.
the class MultiDeviceKeysUpdateJob method onRun.
@Override
public void onRun() throws IOException, UntrustedIdentityException {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
if (SignalStore.account().isLinkedDevice()) {
Log.i(TAG, "Not primary device, aborting...");
return;
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
StorageKey storageServiceKey = SignalStore.storageService().getOrCreateStorageKey();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forKeys(new KeysMessage(Optional.fromNullable(storageServiceKey))), UnidentifiedAccessUtil.getAccessForSync(context));
}
use of org.thoughtcrime.securesms.net.NotPushRegisteredException in project Signal-Android by WhisperSystems.
the class MultiDeviceOutgoingPaymentSyncJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
PaymentDatabase.PaymentTransaction payment = SignalDatabase.payments().getPayment(uuid);
if (payment == null) {
Log.w(TAG, "Payment not found " + uuid);
return;
}
PaymentMetaData.MobileCoinTxoIdentification txoIdentification = payment.getPaymentMetaData().getMobileCoinTxoIdentification();
boolean defrag = payment.isDefrag();
Optional<SignalServiceAddress> uuid;
if (!defrag && payment.getPayee().hasRecipientId()) {
uuid = Optional.of(new SignalServiceAddress(Recipient.resolved(payment.getPayee().requireRecipientId()).requireServiceId()));
} else {
uuid = Optional.absent();
}
byte[] receipt = payment.getReceipt();
if (receipt == null) {
throw new AssertionError("Trying to sync payment before sent?");
}
OutgoingPaymentMessage outgoingPaymentMessage = new OutgoingPaymentMessage(uuid, payment.getAmount().requireMobileCoin(), payment.getFee().requireMobileCoin(), ByteString.copyFrom(receipt), payment.getBlockIndex(), payment.getTimestamp(), defrag ? Optional.absent() : Optional.of(payment.getPayee().requirePublicAddress().serialize()), defrag ? Optional.absent() : Optional.of(payment.getNote()), txoIdentification.getPublicKeyList(), txoIdentification.getKeyImagesList());
ApplicationDependencies.getSignalServiceMessageSender().sendSyncMessage(SignalServiceSyncMessage.forOutgoingPayment(outgoingPaymentMessage), UnidentifiedAccessUtil.getAccessForSync(context));
}
use of org.thoughtcrime.securesms.net.NotPushRegisteredException in project Signal-Android by WhisperSystems.
the class MultiDeviceProfileContentUpdateJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE), UnidentifiedAccessUtil.getAccessForSync(context));
}
Aggregations