mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Impl of sendStoryMessage
Signed-off-by: Scott Lewis <scottslewis@gmail.com>
This commit is contained in:
parent
19e7e1a493
commit
2803976ee5
3 changed files with 11 additions and 12 deletions
|
@ -124,7 +124,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.signalservice.api.SignalSessionLock;
|
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServicePreview;
|
import org.whispersystems.signalservice.api.messages.SignalServicePreview;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceStoryMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceStoryMessage;
|
||||||
|
@ -148,9 +147,6 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
import okio.Utf8;
|
import okio.Utf8;
|
||||||
|
|
||||||
import static org.asamk.signal.manager.config.ServiceConfig.MAX_MESSAGE_SIZE_BYTES;
|
|
||||||
import static org.signal.core.util.StringExtensionsKt.splitByByteLength;
|
|
||||||
|
|
||||||
public class ManagerImpl implements Manager {
|
public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
||||||
|
@ -757,6 +753,7 @@ public class ManagerImpl implements Manager {
|
||||||
return sendMessage(messageBuilder, recipients, notifySelf);
|
return sendMessage(messageBuilder, recipients, notifySelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendStoryMessage(Message message, RecipientIdentifier.Group idGroup
|
public SendMessageResults sendStoryMessage(Message message, RecipientIdentifier.Group idGroup
|
||||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
||||||
|
@ -772,8 +769,8 @@ public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
SignalServiceStoryMessage storyMessage = null;
|
SignalServiceStoryMessage storyMessage = null;
|
||||||
if (attachments != null && attachments.size() > 0) {
|
if (attachments != null && attachments.size() > 0) {
|
||||||
SignalServiceAttachment.Builder attachmentBuilder = new SignalServiceAttachment.Builder().withFileName(attachments.get(0));
|
var attachment = context.getAttachmentHelper().uploadAttachment(attachments.get(0));
|
||||||
storyMessage = SignalServiceStoryMessage.forFileAttachment(profileKey, null, attachmentBuilder.build(), true, bodyRanges);
|
storyMessage = SignalServiceStoryMessage.forFileAttachment(profileKey, null, attachment, true, bodyRanges);
|
||||||
} else {
|
} else {
|
||||||
//SignalServiceTextAttachment textBuilder = new SignalServiceTextAttachment.
|
//SignalServiceTextAttachment textBuilder = new SignalServiceTextAttachment.
|
||||||
//storyMessage = SignalServiceStoryMessage.forTextAttachment(profileKey, ssgroup, textBuilder.build(), true, bodyRanges);
|
//storyMessage = SignalServiceStoryMessage.forTextAttachment(profileKey, ssgroup, textBuilder.build(), true, bodyRanges);
|
||||||
|
@ -1644,5 +1641,4 @@ public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
account = null;
|
account = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,6 +756,4 @@ public interface Signal extends DBusInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
long sendStoryMessage(String messageText, List<String> attachments, byte[] groupId);
|
long sendStoryMessage(String messageText, List<String> attachments, byte[] groupId);
|
||||||
|
|
||||||
//long sendStoryMessage(String messageText, List<String> attachments, byte[] groupId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,13 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
groupIdStrings,
|
groupIdStrings,
|
||||||
usernameStrings);
|
usernameStrings);
|
||||||
|
|
||||||
|
boolean isStory = false;
|
||||||
|
|
||||||
|
if (recipientIdentifiers.size() > 0
|
||||||
|
&& recipientIdentifiers.iterator().next() instanceof RecipientIdentifier.Group) {
|
||||||
|
isStory = Boolean.TRUE.equals(ns.getBoolean("story"));
|
||||||
|
}
|
||||||
|
|
||||||
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
|
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
|
||||||
if (isEndSession) {
|
if (isEndSession) {
|
||||||
final var singleRecipients = recipientIdentifiers.stream()
|
final var singleRecipients = recipientIdentifiers.stream()
|
||||||
|
@ -233,8 +240,6 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
final var editTimestamp = ns.getLong("edit-timestamp");
|
final var editTimestamp = ns.getLong("edit-timestamp");
|
||||||
|
|
||||||
final boolean story = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final var message = new Message(messageText,
|
final var message = new Message(messageText,
|
||||||
attachments,
|
attachments,
|
||||||
|
@ -246,7 +251,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
textStyles);
|
textStyles);
|
||||||
var results = editTimestamp != null
|
var results = editTimestamp != null
|
||||||
? m.sendEditMessage(message, recipientIdentifiers, editTimestamp)
|
? m.sendEditMessage(message, recipientIdentifiers, editTimestamp)
|
||||||
//: story ? // m.sendStoryMessage(message, recipientIdentifiers, notifySelf)
|
: isStory ? m.sendStoryMessage(message, (RecipientIdentifier.Group) recipientIdentifiers.iterator().next())
|
||||||
: m.sendMessage(message, recipientIdentifiers, notifySelf);
|
: m.sendMessage(message, recipientIdentifiers, notifySelf);
|
||||||
outputResult(outputWriter, results);
|
outputResult(outputWriter, results);
|
||||||
} catch (AttachmentInvalidException | IOException e) {
|
} catch (AttachmentInvalidException | IOException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue