Search in sources :

Example 26 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendGroupDataMessage.

/**
 * Sends a {@link SignalServiceDataMessage} to a group using sender keys.
 */
public List<SendMessageResult> sendGroupDataMessage(DistributionId distributionId, List<SignalServiceAddress> recipients, List<UnidentifiedAccess> unidentifiedAccess, boolean isRecipientUpdate, ContentHint contentHint, SignalServiceDataMessage message, SenderKeyGroupEvents sendEvents) throws IOException, UntrustedIdentityException, NoSessionException, InvalidKeyException, InvalidRegistrationIdException {
    Log.d(TAG, "[" + message.getTimestamp() + "] Sending a group data message to " + recipients.size() + " recipients using DistributionId " + distributionId);
    Content content = createMessageContent(message);
    Optional<byte[]> groupId = message.getGroupId();
    List<SendMessageResult> results = sendGroupMessage(distributionId, recipients, unidentifiedAccess, message.getTimestamp(), content, contentHint, groupId.orNull(), false, sendEvents);
    sendEvents.onMessageSent();
    if (store.isMultiDevice()) {
        Content syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.absent(), message.getTimestamp(), results, isRecipientUpdate);
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), message.getTimestamp(), syncMessageContent, false, null);
    }
    sendEvents.onSyncMessageSent();
    return results;
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 27 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method resendContent.

/**
 * Resend a previously-sent message.
 */
public SendMessageResult resendContent(SignalServiceAddress address, Optional<UnidentifiedAccessPair> unidentifiedAccess, long timestamp, Content content, ContentHint contentHint, Optional<byte[]> groupId) throws UntrustedIdentityException, IOException {
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, contentHint, groupId);
    Optional<UnidentifiedAccess> access = unidentifiedAccess.isPresent() ? unidentifiedAccess.get().getTargetUnidentifiedAccess() : Optional.absent();
    return sendMessage(address, access, timestamp, envelopeContent, false, null);
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) UnidentifiedAccess(org.whispersystems.signalservice.api.crypto.UnidentifiedAccess)

Example 28 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendSyncMessage.

public SendMessageResult sendSyncMessage(SignalServiceSyncMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException {
    Content content;
    if (message.getContacts().isPresent()) {
        content = createMultiDeviceContactsContent(message.getContacts().get().getContactsStream().asStream(), message.getContacts().get().isComplete());
    } else if (message.getGroups().isPresent()) {
        content = createMultiDeviceGroupsContent(message.getGroups().get().asStream());
    } else if (message.getRead().isPresent()) {
        content = createMultiDeviceReadContent(message.getRead().get());
    } else if (message.getViewed().isPresent()) {
        content = createMultiDeviceViewedContent(message.getViewed().get());
    } else if (message.getViewOnceOpen().isPresent()) {
        content = createMultiDeviceViewOnceOpenContent(message.getViewOnceOpen().get());
    } else if (message.getBlockedList().isPresent()) {
        content = createMultiDeviceBlockedContent(message.getBlockedList().get());
    } else if (message.getConfiguration().isPresent()) {
        content = createMultiDeviceConfigurationContent(message.getConfiguration().get());
    } else if (message.getSent().isPresent()) {
        content = createMultiDeviceSentTranscriptContent(message.getSent().get(), unidentifiedAccess.isPresent());
    } else if (message.getStickerPackOperations().isPresent()) {
        content = createMultiDeviceStickerPackOperationContent(message.getStickerPackOperations().get());
    } else if (message.getFetchType().isPresent()) {
        content = createMultiDeviceFetchTypeContent(message.getFetchType().get());
    } else if (message.getMessageRequestResponse().isPresent()) {
        content = createMultiDeviceMessageRequestResponseContent(message.getMessageRequestResponse().get());
    } else if (message.getOutgoingPaymentMessage().isPresent()) {
        content = createMultiDeviceOutgoingPaymentContent(message.getOutgoingPaymentMessage().get());
    } else if (message.getKeys().isPresent()) {
        content = createMultiDeviceSyncKeysContent(message.getKeys().get());
    } else if (message.getVerified().isPresent()) {
        return sendVerifiedSyncMessage(message.getVerified().get());
    } else if (message.getRequest().isPresent()) {
        content = createRequestContent(message.getRequest().get().getRequest());
    } else {
        throw new IOException("Unsupported sync message!");
    }
    long timestamp = message.getSent().isPresent() ? message.getSent().get().getTimestamp() : System.currentTimeMillis();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    return sendMessage(localAddress, Optional.absent(), timestamp, envelopeContent, false, null);
}
Also used : EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) IOException(java.io.IOException) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Aggregations

EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)28 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)26 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)24 SendMessageResult (org.whispersystems.signalservice.api.messages.SendMessageResult)8 NullMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage)4 ByteString (com.google.protobuf.ByteString)2 IOException (java.io.IOException)2 UnidentifiedAccess (org.whispersystems.signalservice.api.crypto.UnidentifiedAccess)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2