Add simplification for single recipient reactions

This commit is contained in:
AsamK 2024-11-24 11:51:54 +01:00
parent 26b5a4c582
commit fe752e0c79

View file

@ -11,6 +11,7 @@ import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.GroupNotFoundException; import org.asamk.signal.manager.api.GroupNotFoundException;
import org.asamk.signal.manager.api.GroupSendingNotAllowedException; import org.asamk.signal.manager.api.GroupSendingNotAllowedException;
import org.asamk.signal.manager.api.NotAGroupMemberException; 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.manager.api.UnregisteredRecipientException;
import org.asamk.signal.output.OutputWriter; import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil; import org.asamk.signal.util.CommandUtil;
@ -74,10 +75,18 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
final var targetTimestamp = ns.getLong("target-timestamp"); final var targetTimestamp = ns.getLong("target-timestamp");
final var isStory = Boolean.TRUE.equals(ns.getBoolean("story")); 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 { try {
final var results = m.sendMessageReaction(emoji, final var results = m.sendMessageReaction(emoji,
isRemove, isRemove,
CommandUtil.getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()), targetAuthorIdentifier,
targetTimestamp, targetTimestamp,
recipientIdentifiers, recipientIdentifiers,
isStory); isStory);