Search in sources :

Example 21 with IncomingTextMessage

use of org.thoughtcrime.securesms.sms.IncomingTextMessage in project Signal-Android by WhisperSystems.

the class MessageContentProcessor method insertPlaceholder.

private Optional<InsertResult> insertPlaceholder(@NonNull String sender, int senderDevice, long timestamp, Optional<GroupId> groupId) {
    MessageDatabase database = SignalDatabase.sms();
    IncomingTextMessage textMessage = new IncomingTextMessage(Recipient.external(context, sender).getId(), senderDevice, timestamp, -1, System.currentTimeMillis(), "", groupId, 0, false, null);
    textMessage = new IncomingEncryptedMessage(textMessage, "");
    return database.insertMessageInbox(textMessage);
}
Also used : IncomingEncryptedMessage(org.thoughtcrime.securesms.sms.IncomingEncryptedMessage) MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage)

Example 22 with IncomingTextMessage

use of org.thoughtcrime.securesms.sms.IncomingTextMessage in project Signal-Android by WhisperSystems.

the class IdentityUtil method markIdentityUpdate.

public static void markIdentityUpdate(@NonNull Context context, @NonNull RecipientId recipientId) {
    long time = System.currentTimeMillis();
    MessageDatabase smsDatabase = SignalDatabase.sms();
    GroupDatabase groupDatabase = SignalDatabase.groups();
    try (GroupDatabase.Reader reader = groupDatabase.getGroups()) {
        GroupDatabase.GroupRecord groupRecord;
        while ((groupRecord = reader.getNext()) != null) {
            if (groupRecord.getMembers().contains(recipientId) && groupRecord.isActive()) {
                IncomingTextMessage incoming = new IncomingTextMessage(recipientId, 1, time, time, time, null, Optional.of(groupRecord.getId()), 0, false, null);
                IncomingIdentityUpdateMessage groupUpdate = new IncomingIdentityUpdateMessage(incoming);
                smsDatabase.insertMessageInbox(groupUpdate);
            }
        }
    }
    IncomingTextMessage incoming = new IncomingTextMessage(recipientId, 1, time, -1, time, null, Optional.absent(), 0, false, null);
    IncomingIdentityUpdateMessage individualUpdate = new IncomingIdentityUpdateMessage(incoming);
    Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(individualUpdate);
    if (insertResult.isPresent()) {
        ApplicationDependencies.getMessageNotifier().updateNotification(context, insertResult.get().getThreadId());
    }
}
Also used : IncomingIdentityUpdateMessage(org.thoughtcrime.securesms.sms.IncomingIdentityUpdateMessage) InsertResult(org.thoughtcrime.securesms.database.MessageDatabase.InsertResult) MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase)

Aggregations

IncomingTextMessage (org.thoughtcrime.securesms.sms.IncomingTextMessage)22 InsertResult (org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult)10 MessageDatabase (org.thoughtcrime.securesms.database.MessageDatabase)7 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)7 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)6 InsertResult (org.thoughtcrime.securesms.database.MessageDatabase.InsertResult)6 Recipient (org.thoughtcrime.securesms.recipients.Recipient)6 IncomingEncryptedMessage (org.thoughtcrime.securesms.sms.IncomingEncryptedMessage)6 Recipients (org.thoughtcrime.securesms.recipients.Recipients)4 Nullable (androidx.annotation.Nullable)3 ByteString (com.google.protobuf.ByteString)3 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)3 IncomingEndSessionMessage (org.thoughtcrime.securesms.sms.IncomingEndSessionMessage)3 Nullable (android.support.annotation.Nullable)2 TextSecureSessionStore (org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore)2 Address (org.thoughtcrime.securesms.database.Address)2 SyncMessageId (org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)2 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)2 MessageId (org.thoughtcrime.securesms.database.model.MessageId)2 AvatarDownloadJob (org.thoughtcrime.securesms.jobs.AvatarDownloadJob)2