Search in sources :

Example 6 with ReactionRecord

use of org.thoughtcrime.securesms.database.model.ReactionRecord in project Signal-Android by WhisperSystems.

the class MessageSender method sendNewReaction.

public static void sendNewReaction(@NonNull Context context, @NonNull MessageId messageId, @NonNull String emoji) {
    ReactionRecord reaction = new ReactionRecord(emoji, Recipient.self().getId(), System.currentTimeMillis(), System.currentTimeMillis());
    SignalDatabase.reactions().addReaction(messageId, reaction);
    try {
        ApplicationDependencies.getJobManager().add(ReactionSendJob.create(context, messageId, reaction, false));
        onMessageSent();
    } catch (NoSuchMessageException e) {
        Log.w(TAG, "[sendNewReaction] Could not find message! Ignoring.");
    }
}
Also used : NoSuchMessageException(org.thoughtcrime.securesms.database.NoSuchMessageException) ReactionRecord(org.thoughtcrime.securesms.database.model.ReactionRecord)

Example 7 with ReactionRecord

use of org.thoughtcrime.securesms.database.model.ReactionRecord in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method onReactionSelected.

@Override
public void onReactionSelected(MessageRecord messageRecord, String emoji) {
    final Context context = requireContext().getApplicationContext();
    reactionDelegate.hide();
    SignalExecutors.BOUNDED.execute(() -> {
        ReactionRecord oldRecord = Stream.of(messageRecord.getReactions()).filter(record -> record.getAuthor().equals(Recipient.self().getId())).findFirst().orElse(null);
        if (oldRecord != null && oldRecord.getEmoji().equals(emoji)) {
            MessageSender.sendReactionRemoval(context, new MessageId(messageRecord.getId(), messageRecord.isMms()), oldRecord);
        } else {
            MessageSender.sendNewReaction(context, new MessageId(messageRecord.getId(), messageRecord.isMms()), emoji);
        }
    });
}
Also used : Context(android.content.Context) ReactionRecord(org.thoughtcrime.securesms.database.model.ReactionRecord) MessageId(org.thoughtcrime.securesms.database.model.MessageId)

Example 8 with ReactionRecord

use of org.thoughtcrime.securesms.database.model.ReactionRecord in project Signal-Android by WhisperSystems.

the class ReactWithAnyEmojiRepository method addEmojiToMessage.

void addEmojiToMessage(@NonNull String emoji, @NonNull MessageId messageId) {
    SignalExecutors.BOUNDED.execute(() -> {
        ReactionRecord oldRecord = Stream.of(SignalDatabase.reactions().getReactions(messageId)).filter(record -> record.getAuthor().equals(Recipient.self().getId())).findFirst().orElse(null);
        if (oldRecord != null && oldRecord.getEmoji().equals(emoji)) {
            MessageSender.sendReactionRemoval(context, messageId, oldRecord);
        } else {
            MessageSender.sendNewReaction(context, messageId, emoji);
            ThreadUtil.runOnMain(() -> recentEmojiPageModel.onCodePointSelected(emoji));
        }
    });
}
Also used : ReactionRecord(org.thoughtcrime.securesms.database.model.ReactionRecord)

Aggregations

ReactionRecord (org.thoughtcrime.securesms.database.model.ReactionRecord)8 MessageId (org.thoughtcrime.securesms.database.model.MessageId)3 MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)3 Context (android.content.Context)2 Nullable (androidx.annotation.Nullable)2 InMemoryMessageRecord (org.thoughtcrime.securesms.database.model.InMemoryMessageRecord)2 MediaMmsMessageRecord (org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)2 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)2 SuppressLint (android.annotation.SuppressLint)1 NonNull (androidx.annotation.NonNull)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 DatabaseAttachment (org.thoughtcrime.securesms.attachments.DatabaseAttachment)1 MessageDatabase (org.thoughtcrime.securesms.database.MessageDatabase)1 SyncMessageId (org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)1 NoSuchMessageException (org.thoughtcrime.securesms.database.NoSuchMessageException)1 Mention (org.thoughtcrime.securesms.database.model.Mention)1 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)1 ThreadRecord (org.thoughtcrime.securesms.database.model.ThreadRecord)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1