Reply with emoji is reaction

(cherry picked from commit ad405bfb0c536dca03decd4e33d92dfab6f65c64)
This commit is contained in:
Stephen Paul Weber 2024-09-30 13:42:23 -05:00 committed by Arne
parent 96dd610d4f
commit 2ce7b8859b
3 changed files with 17 additions and 18 deletions

View file

@ -465,20 +465,6 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
setInReplyTo(replyTo);
}
public Message react(String emoji) {
final var m = reply();
if (getReactionsEl() == null) {
m.updateReaction(this, emoji);
} else if (mInReplyTo != null) {
// Try to send react-to-reaction to parent
m.updateReaction(mInReplyTo, emoji);
} else {
// Do not send react-to-reaction
m.updateReplyTo(this, new SpannableStringBuilder(emoji));
}
return m;
}
public void updateReaction(final Message reactTo, String emoji) {
Set<String> emojis = new HashSet<>();
if (conversation instanceof Conversation) emojis = ((Conversation) conversation).findReactionsTo(reactTo.replyId(), null);

View file

@ -63,9 +63,10 @@ import de.monocles.chat.WebxdcUpdate;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.collect.Multimap;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.io.Files;
import com.kedia.ogparser.JsoupProxy;
@ -1278,8 +1279,13 @@ public class XmppConnectionService extends Service {
final Message inReplyTo = lastMessageUuid == null ? null : conversation.findMessageWithUuid(lastMessageUuid);
Message message = new Message(conversation, body, conversation.getNextEncryption());
if (inReplyTo != null) {
if (Emoticons.isEmoji(body)) {
message = inReplyTo.react(body);
if (Emoticons.isEmoji(body.replaceAll("\\s", ""))) {
final var aggregated = inReplyTo.getAggregatedReactions();
final ImmutableSet.Builder<String> reactionBuilder = new ImmutableSet.Builder<>();
reactionBuilder.addAll(aggregated.ourReactions);
reactionBuilder.add(body.replaceAll("\\s", ""));
sendReactions(inReplyTo, reactionBuilder.build());
return;
} else {
message = inReplyTo.reply();
}

View file

@ -1090,7 +1090,14 @@ public class ConversationFragment extends XmppFragment
}
if (conversation.getReplyTo() != null) {
if (Emoticons.isEmoji(body.toString().replaceAll("\\s", ""))) {
message = conversation.getReplyTo().react(body.toString().replaceAll("\\s", ""));
final var aggregated = conversation.getReplyTo().getAggregatedReactions();
final ImmutableSet.Builder<String> reactionBuilder = new ImmutableSet.Builder<>();
reactionBuilder.addAll(aggregated.ourReactions);
reactionBuilder.add(body.toString().replaceAll("\\s", ""));
activity.xmppConnectionService.sendReactions(conversation.getReplyTo(), reactionBuilder.build());
setupReply(null);
messageSent();
return;
} else {
message = conversation.getReplyTo().reply();
message.appendBody(body);