mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Added sendStoryMessage
This commit is contained in:
parent
fab1b96c21
commit
811dc0dcf3
5 changed files with 601 additions and 607 deletions
|
@ -189,6 +189,10 @@ public interface Manager extends Closeable {
|
|||
Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
||||
|
||||
SendMessageResults sendStoryMessage(
|
||||
Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
||||
|
||||
SendMessageResults sendEditMessage(
|
||||
Message message, Set<RecipientIdentifier> recipients, long editTargetTimestamp
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
||||
|
|
|
@ -96,6 +96,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.StoryContext;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServicePreview;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||
|
@ -736,6 +737,21 @@ public class ManagerImpl implements Manager {
|
|||
return sendMessage(messageBuilder, recipients, notifySelf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendStoryMessage(
|
||||
Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
||||
final var selfProfile = context.getProfileHelper().getSelfProfile();
|
||||
if (selfProfile == null || selfProfile.getDisplayName().isEmpty()) {
|
||||
logger.warn(
|
||||
"No profile name set. When sending a message it's recommended to set a profile name with the updateProfile command. This may become mandatory in the future.");
|
||||
}
|
||||
final var messageBuilder = SignalServiceDataMessage.newBuilder();
|
||||
applyMessage(messageBuilder, message);
|
||||
messageBuilder.withStoryContext(new StoryContext(account.getSelfAddress().getServiceId(), System.currentTimeMillis()));
|
||||
return sendMessage(messageBuilder, recipients, notifySelf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendEditMessage(
|
||||
Message message, Set<RecipientIdentifier> recipients, long editTargetTimestamp
|
||||
|
|
|
@ -15,8 +15,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DBus interface for the org.asamk.Signal service.
|
||||
* Including emitted Signals and returned Errors.
|
||||
* DBus interface for the org.asamk.Signal service. Including emitted Signals
|
||||
* and returned Errors.
|
||||
*/
|
||||
public interface Signal extends DBusInterface {
|
||||
|
||||
|
@ -26,41 +26,28 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void unsubscribeReceive();
|
||||
|
||||
long sendMessage(
|
||||
String message, List<String> attachments, String recipient
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
long sendMessage(String message, List<String> attachments, String recipient)
|
||||
throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
long sendMessage(
|
||||
String message, List<String> attachments, List<String> recipients
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
long sendMessage(String message, List<String> attachments, List<String> recipients)
|
||||
throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
void sendTyping(
|
||||
String recipient, boolean stop
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendTyping(String recipient, boolean stop) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
void sendReadReceipt(
|
||||
String recipient, List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendReadReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
void sendViewedReceipt(
|
||||
String recipient, List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendViewedReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
long sendRemoteDeleteMessage(
|
||||
long targetSentTimestamp, String recipient
|
||||
) throws Error.Failure, Error.InvalidNumber;
|
||||
long sendRemoteDeleteMessage(long targetSentTimestamp, String recipient) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendRemoteDeleteMessage(
|
||||
long targetSentTimestamp, List<String> recipients
|
||||
) throws Error.Failure, Error.InvalidNumber;
|
||||
long sendRemoteDeleteMessage(long targetSentTimestamp, List<String> recipients)
|
||||
throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
|
||||
) throws Error.InvalidNumber, Error.Failure;
|
||||
long sendMessageReaction(String emoji, boolean remove, String targetAuthor, long targetSentTimestamp,
|
||||
String recipient) throws Error.InvalidNumber, Error.Failure;
|
||||
|
||||
long sendMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
||||
) throws Error.InvalidNumber, Error.Failure;
|
||||
long sendMessageReaction(String emoji, boolean remove, String targetAuthor, long targetSentTimestamp,
|
||||
List<String> recipients) throws Error.InvalidNumber, Error.Failure;
|
||||
|
||||
long sendPaymentNotification(byte[] receipt, String note, String recipient) throws Error.Failure;
|
||||
|
||||
|
@ -68,31 +55,28 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void sendSyncRequest() throws Error.Failure;
|
||||
|
||||
long sendNoteToSelfMessage(
|
||||
String message, List<String> attachments
|
||||
) throws Error.AttachmentInvalid, Error.Failure;
|
||||
long sendNoteToSelfMessage(String message, List<String> attachments) throws Error.AttachmentInvalid, Error.Failure;
|
||||
|
||||
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
void sendEndSessionMessage(List<String> recipients)
|
||||
throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
void deleteRecipient(final String recipient) throws Error.Failure;
|
||||
|
||||
void deleteContact(final String recipient) throws Error.Failure;
|
||||
|
||||
long sendGroupMessage(
|
||||
String message, List<String> attachments, byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
|
||||
long sendGroupMessage(String message, List<String> attachments, byte[] groupId)
|
||||
throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
|
||||
|
||||
void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||
long sendStoryMessage(String messageText, List<String> attachments, byte[] groupId);
|
||||
|
||||
long sendGroupRemoteDeleteMessage(
|
||||
long targetSentTimestamp, byte[] groupId
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
void sendGroupTyping(final byte[] groupId, final boolean stop)
|
||||
throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||
|
||||
long sendGroupMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||
long sendGroupRemoteDeleteMessage(long targetSentTimestamp, byte[] groupId)
|
||||
throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
long sendGroupMessageReaction(String emoji, boolean remove, String targetAuthor, long targetSentTimestamp,
|
||||
byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||
|
||||
String getContactName(String number) throws Error.InvalidNumber;
|
||||
|
||||
|
@ -118,14 +102,12 @@ public interface Signal extends DBusInterface {
|
|||
@Deprecated
|
||||
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
||||
|
||||
byte[] createGroup(
|
||||
String name, List<String> members, String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
|
||||
byte[] createGroup(String name, List<String> members, String avatar)
|
||||
throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
|
||||
|
||||
@Deprecated
|
||||
byte[] updateGroup(
|
||||
byte[] groupId, String name, List<String> members, String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
byte[] updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws Error.AttachmentInvalid,
|
||||
Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
@Deprecated
|
||||
boolean isRegistered() throws Error.Failure, Error.InvalidNumber;
|
||||
|
@ -146,18 +128,11 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
DBusPath getThisDevice();
|
||||
|
||||
void updateProfile(
|
||||
String givenName,
|
||||
String familyName,
|
||||
String about,
|
||||
String aboutEmoji,
|
||||
String avatarPath,
|
||||
boolean removeAvatar
|
||||
) throws Error.Failure;
|
||||
void updateProfile(String givenName, String familyName, String about, String aboutEmoji, String avatarPath,
|
||||
boolean removeAvatar) throws Error.Failure;
|
||||
|
||||
void updateProfile(
|
||||
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
||||
) throws Error.Failure;
|
||||
void updateProfile(String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar)
|
||||
throws Error.Failure;
|
||||
|
||||
void removePin();
|
||||
|
||||
|
@ -198,14 +173,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String message;
|
||||
private final Map<String, Variant<?>> extras;
|
||||
|
||||
public MessageReceivedV2(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
String sender,
|
||||
byte[] groupId,
|
||||
String message,
|
||||
final Map<String, Variant<?>> extras
|
||||
) throws DBusException {
|
||||
public MessageReceivedV2(String objectpath, long timestamp, String sender, byte[] groupId, String message,
|
||||
final Map<String, Variant<?>> extras) throws DBusException {
|
||||
super(objectpath, timestamp, sender, groupId, message, extras);
|
||||
this.timestamp = timestamp;
|
||||
this.sender = sender;
|
||||
|
@ -244,15 +213,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String message;
|
||||
private final Map<String, Variant<?>> extras;
|
||||
|
||||
public EditMessageReceived(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
final long targetSentTimestamp,
|
||||
String sender,
|
||||
byte[] groupId,
|
||||
String message,
|
||||
final Map<String, Variant<?>> extras
|
||||
) throws DBusException {
|
||||
public EditMessageReceived(String objectpath, long timestamp, final long targetSentTimestamp, String sender,
|
||||
byte[] groupId, String message, final Map<String, Variant<?>> extras) throws DBusException {
|
||||
super(objectpath, timestamp, targetSentTimestamp, sender, groupId, message, extras);
|
||||
this.timestamp = timestamp;
|
||||
this.targetSentTimestamp = targetSentTimestamp;
|
||||
|
@ -295,14 +257,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String message;
|
||||
private final List<String> attachments;
|
||||
|
||||
public MessageReceived(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
String sender,
|
||||
byte[] groupId,
|
||||
String message,
|
||||
List<String> attachments
|
||||
) throws DBusException {
|
||||
public MessageReceived(String objectpath, long timestamp, String sender, byte[] groupId, String message,
|
||||
List<String> attachments) throws DBusException {
|
||||
super(objectpath, timestamp, sender, groupId, message, attachments);
|
||||
this.timestamp = timestamp;
|
||||
this.sender = sender;
|
||||
|
@ -359,13 +315,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String type;
|
||||
private final Map<String, Variant<?>> extras;
|
||||
|
||||
public ReceiptReceivedV2(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
String sender,
|
||||
final String type,
|
||||
final Map<String, Variant<?>> extras
|
||||
) throws DBusException {
|
||||
public ReceiptReceivedV2(String objectpath, long timestamp, String sender, final String type,
|
||||
final Map<String, Variant<?>> extras) throws DBusException {
|
||||
super(objectpath, timestamp, sender, type, extras);
|
||||
this.timestamp = timestamp;
|
||||
this.sender = sender;
|
||||
|
@ -399,15 +350,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String message;
|
||||
private final List<String> attachments;
|
||||
|
||||
public SyncMessageReceived(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
String source,
|
||||
String destination,
|
||||
byte[] groupId,
|
||||
String message,
|
||||
List<String> attachments
|
||||
) throws DBusException {
|
||||
public SyncMessageReceived(String objectpath, long timestamp, String source, String destination, byte[] groupId,
|
||||
String message, List<String> attachments) throws DBusException {
|
||||
super(objectpath, timestamp, source, destination, groupId, message, attachments);
|
||||
this.timestamp = timestamp;
|
||||
this.source = source;
|
||||
|
@ -451,15 +395,8 @@ public interface Signal extends DBusInterface {
|
|||
private final String message;
|
||||
private final Map<String, Variant<?>> extras;
|
||||
|
||||
public SyncMessageReceivedV2(
|
||||
String objectpath,
|
||||
long timestamp,
|
||||
String source,
|
||||
String destination,
|
||||
byte[] groupId,
|
||||
String message,
|
||||
final Map<String, Variant<?>> extras
|
||||
) throws DBusException {
|
||||
public SyncMessageReceivedV2(String objectpath, long timestamp, String source, String destination,
|
||||
byte[] groupId, String message, final Map<String, Variant<?>> extras) throws DBusException {
|
||||
super(objectpath, timestamp, source, destination, groupId, message, extras);
|
||||
this.timestamp = timestamp;
|
||||
this.source = source;
|
||||
|
@ -537,7 +474,8 @@ public interface Signal extends DBusInterface {
|
|||
@DBusProperty(name = "UnidentifiedDeliveryIndicators", type = Boolean.class)
|
||||
@DBusProperty(name = "TypingIndicators", type = Boolean.class)
|
||||
@DBusProperty(name = "LinkPreviews", type = Boolean.class)
|
||||
interface Configuration extends DBusInterface, Properties {}
|
||||
interface Configuration extends DBusInterface, Properties {
|
||||
}
|
||||
|
||||
class StructGroup extends Struct {
|
||||
|
||||
|
@ -734,4 +672,5 @@ public interface Signal extends DBusInterface {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -420,6 +420,16 @@ public class DbusManagerImpl implements Manager {
|
|||
groupId -> signal.sendGroupMessage(message.messageText(), message.attachments(), groupId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendStoryMessage(
|
||||
final Message message, final Set<RecipientIdentifier> recipients, final boolean notifySelf
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||
return handleMessage(recipients,
|
||||
numbers -> signal.sendMessage(message.messageText(), message.attachments(), numbers),
|
||||
() -> signal.sendNoteToSelfMessage(message.messageText(), message.attachments()),
|
||||
groupId -> signal.sendStoryMessage(message.messageText(), message.attachments(), groupId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendEditMessage(
|
||||
final Message message, final Set<RecipientIdentifier> recipients, final long editTargetTimestamp
|
||||
|
|
|
@ -459,6 +459,31 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendStoryMessage(final String messageText, final List<String> attachments, final byte[] groupId) {
|
||||
try {
|
||||
final var message = new Message(messageText,
|
||||
attachments,
|
||||
List.of(),
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
List.of(),
|
||||
Optional.empty(),
|
||||
List.of());
|
||||
var results = m.sendStoryMessage(message, Set.of(getGroupRecipientIdentifier(groupId)), false);
|
||||
checkSendMessageResults(results);
|
||||
return results.timestamp();
|
||||
} catch (IOException | InvalidStickerException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||
throw new Error.GroupNotFound(e.getMessage());
|
||||
} catch (AttachmentInvalidException e) {
|
||||
throw new Error.AttachmentInvalid(e.getMessage());
|
||||
} catch (UnregisteredRecipientException e) {
|
||||
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue