Skip to content

Commit

Permalink
Add simplification for single recipient reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
AsamK committed Nov 24, 2024
1 parent 26b5a4c commit fe752e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/org/asamk/signal/commands/SendReactionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.asamk.signal.manager.api.GroupNotFoundException;
import org.asamk.signal.manager.api.GroupSendingNotAllowedException;
import org.asamk.signal.manager.api.NotAGroupMemberException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.UnregisteredRecipientException;
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil;
Expand Down Expand Up @@ -74,10 +75,18 @@ public void handleCommand(
final var targetTimestamp = ns.getLong("target-timestamp");
final var isStory = Boolean.TRUE.equals(ns.getBoolean("story"));

final RecipientIdentifier.Single targetAuthorIdentifier;
if (targetAuthor == null && recipientIdentifiers.size() == 1 && recipientIdentifiers.stream()
.findFirst()
.get() instanceof RecipientIdentifier.Single single) {
targetAuthorIdentifier = single;
} else {
targetAuthorIdentifier = CommandUtil.getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber());
}
try {
final var results = m.sendMessageReaction(emoji,
isRemove,
CommandUtil.getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
targetAuthorIdentifier,
targetTimestamp,
recipientIdentifiers,
isStory);
Expand Down

0 comments on commit fe752e0

Please sign in to comment.