Esempio n. 1
0
  private Pair<Long, Long> insertSyncMediaMessage(
      MasterSecret masterSecret, TextSecureEnvelope envelope, TextSecureMessage message)
      throws MmsException {
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    TextSecureSyncContext syncContext = message.getSyncContext().get();
    Recipients recipients = getSyncMessageDestination(message);
    OutgoingMediaMessage mediaMessage =
        new OutgoingMediaMessage(
            context,
            masterSecret,
            recipients,
            message.getAttachments().get(),
            message.getBody().orNull());

    mediaMessage = new OutgoingSecureMediaMessage(mediaMessage);

    long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
    long messageId =
        database.insertMessageOutbox(
            masterSecret, mediaMessage, threadId, false, syncContext.getTimestamp());

    database.markAsSent(messageId, "push".getBytes(), 0);
    database.markAsPush(messageId);

    return new Pair<>(messageId, threadId);
  }
Esempio n. 2
0
  private Pair<Long, Long> insertStandardMediaMessage(
      MasterSecret masterSecret, TextSecureEnvelope envelope, TextSecureMessage message)
      throws MmsException {
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    String localNumber = TextSecurePreferences.getLocalNumber(context);
    IncomingMediaMessage mediaMessage =
        new IncomingMediaMessage(
            masterSecret,
            envelope.getSource(),
            localNumber,
            message.getTimestamp(),
            Optional.fromNullable(envelope.getRelay()),
            message.getBody(),
            message.getGroupInfo(),
            message.getAttachments());

    return database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);
  }