Implement reacting to stories
This commit is contained in:
parent
207764e0be
commit
fea19c9e20
@ -193,6 +193,9 @@ pub enum CliCommands {
|
|||||||
|
|
||||||
#[arg(short = 'r', long)]
|
#[arg(short = 'r', long)]
|
||||||
remove: bool,
|
remove: bool,
|
||||||
|
|
||||||
|
#[arg(long)]
|
||||||
|
story: bool,
|
||||||
},
|
},
|
||||||
SendReceipt {
|
SendReceipt {
|
||||||
recipient: String,
|
recipient: String,
|
||||||
|
@ -155,6 +155,7 @@ pub trait Rpc {
|
|||||||
#[allow(non_snake_case)] targetAuthor: String,
|
#[allow(non_snake_case)] targetAuthor: String,
|
||||||
#[allow(non_snake_case)] targetTimestamp: u64,
|
#[allow(non_snake_case)] targetTimestamp: u64,
|
||||||
remove: bool,
|
remove: bool,
|
||||||
|
story: bool,
|
||||||
) -> Result<Value>;
|
) -> Result<Value>;
|
||||||
|
|
||||||
#[rpc(name = "sendReceipt", params = "named")]
|
#[rpc(name = "sendReceipt", params = "named")]
|
||||||
|
@ -164,6 +164,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||||||
target_author,
|
target_author,
|
||||||
target_timestamp,
|
target_timestamp,
|
||||||
remove,
|
remove,
|
||||||
|
story,
|
||||||
} => {
|
} => {
|
||||||
client
|
client
|
||||||
.send_reaction(
|
.send_reaction(
|
||||||
@ -175,6 +176,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||||||
target_author,
|
target_author,
|
||||||
target_timestamp,
|
target_timestamp,
|
||||||
remove,
|
remove,
|
||||||
|
story,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,8 @@ public interface Manager extends Closeable {
|
|||||||
boolean remove,
|
boolean remove,
|
||||||
RecipientIdentifier.Single targetAuthor,
|
RecipientIdentifier.Single targetAuthor,
|
||||||
long targetSentTimestamp,
|
long targetSentTimestamp,
|
||||||
Set<RecipientIdentifier> recipients
|
Set<RecipientIdentifier> recipients,
|
||||||
|
final boolean isStory
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendMessageResults sendPaymentNotificationMessage(
|
SendMessageResults sendPaymentNotificationMessage(
|
||||||
|
@ -667,14 +667,19 @@ class ManagerImpl implements Manager {
|
|||||||
boolean remove,
|
boolean remove,
|
||||||
RecipientIdentifier.Single targetAuthor,
|
RecipientIdentifier.Single targetAuthor,
|
||||||
long targetSentTimestamp,
|
long targetSentTimestamp,
|
||||||
Set<RecipientIdentifier> recipients
|
Set<RecipientIdentifier> recipients,
|
||||||
|
final boolean isStory
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
||||||
var targetAuthorRecipientId = context.getRecipientHelper().resolveRecipient(targetAuthor);
|
var targetAuthorRecipientId = context.getRecipientHelper().resolveRecipient(targetAuthor);
|
||||||
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
final var authorServiceId = context.getRecipientHelper()
|
||||||
remove,
|
.resolveSignalServiceAddress(targetAuthorRecipientId)
|
||||||
context.getRecipientHelper().resolveSignalServiceAddress(targetAuthorRecipientId).getServiceId(),
|
.getServiceId();
|
||||||
targetSentTimestamp);
|
var reaction = new SignalServiceDataMessage.Reaction(emoji, remove, authorServiceId, targetSentTimestamp);
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
||||||
|
if (isStory) {
|
||||||
|
messageBuilder.withStoryContext(new SignalServiceDataMessage.StoryContext(authorServiceId,
|
||||||
|
targetSentTimestamp));
|
||||||
|
}
|
||||||
return sendMessage(messageBuilder, recipients);
|
return sendMessage(messageBuilder, recipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +313,9 @@ Specify the timestamp of the message to which to react.
|
|||||||
*-r*, *--remove*::
|
*-r*, *--remove*::
|
||||||
Remove a reaction.
|
Remove a reaction.
|
||||||
|
|
||||||
|
*--story*::
|
||||||
|
React to a story instead of a normal message
|
||||||
|
|
||||||
=== sendReceipt
|
=== sendReceipt
|
||||||
|
|
||||||
Send a read or viewed receipt to a previously received message.
|
Send a read or viewed receipt to a previously received message.
|
||||||
|
@ -45,6 +45,9 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
|||||||
.type(long.class)
|
.type(long.class)
|
||||||
.help("Specify the timestamp of the message to which to react.");
|
.help("Specify the timestamp of the message to which to react.");
|
||||||
subparser.addArgument("-r", "--remove").help("Remove a reaction.").action(Arguments.storeTrue());
|
subparser.addArgument("-r", "--remove").help("Remove a reaction.").action(Arguments.storeTrue());
|
||||||
|
subparser.addArgument("--story")
|
||||||
|
.help("React to a story instead of a normal message")
|
||||||
|
.action(Arguments.storeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,13 +67,15 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
|||||||
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
|
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
|
||||||
final var targetAuthor = ns.getString("target-author");
|
final var targetAuthor = ns.getString("target-author");
|
||||||
final var targetTimestamp = ns.getLong("target-timestamp");
|
final var targetTimestamp = ns.getLong("target-timestamp");
|
||||||
|
final var isStory = Boolean.TRUE.equals(ns.getBoolean("story"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final var results = m.sendMessageReaction(emoji,
|
final var results = m.sendMessageReaction(emoji,
|
||||||
isRemove,
|
isRemove,
|
||||||
CommandUtil.getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
|
CommandUtil.getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
|
||||||
targetTimestamp,
|
targetTimestamp,
|
||||||
recipientIdentifiers);
|
recipientIdentifiers,
|
||||||
|
isStory);
|
||||||
outputResult(outputWriter, results);
|
outputResult(outputWriter, results);
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new UserErrorException(e.getMessage());
|
throw new UserErrorException(e.getMessage());
|
||||||
|
@ -364,7 +364,8 @@ public class DbusManagerImpl implements Manager {
|
|||||||
final boolean remove,
|
final boolean remove,
|
||||||
final RecipientIdentifier.Single targetAuthor,
|
final RecipientIdentifier.Single targetAuthor,
|
||||||
final long targetSentTimestamp,
|
final long targetSentTimestamp,
|
||||||
final Set<RecipientIdentifier> recipients
|
final Set<RecipientIdentifier> recipients,
|
||||||
|
final boolean isStory
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
return handleMessage(recipients,
|
return handleMessage(recipients,
|
||||||
numbers -> signal.sendMessageReaction(emoji,
|
numbers -> signal.sendMessageReaction(emoji,
|
||||||
|
@ -287,7 +287,8 @@ public class DbusSignalImpl implements Signal {
|
|||||||
targetSentTimestamp,
|
targetSentTimestamp,
|
||||||
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
||||||
.map(RecipientIdentifier.class::cast)
|
.map(RecipientIdentifier.class::cast)
|
||||||
.collect(Collectors.toSet()));
|
.collect(Collectors.toSet()),
|
||||||
|
false);
|
||||||
checkSendMessageResults(results);
|
checkSendMessageResults(results);
|
||||||
return results.timestamp();
|
return results.timestamp();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -485,7 +486,8 @@ public class DbusSignalImpl implements Signal {
|
|||||||
remove,
|
remove,
|
||||||
getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
|
getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
|
||||||
targetSentTimestamp,
|
targetSentTimestamp,
|
||||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
Set.of(getGroupRecipientIdentifier(groupId)),
|
||||||
|
false);
|
||||||
checkSendMessageResults(results);
|
checkSendMessageResults(results);
|
||||||
return results.timestamp();
|
return results.timestamp();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user