Impl of sendStoryMessage

Signed-off-by: Scott Lewis <scottslewis@gmail.com>
This commit is contained in:
Scott Lewis 2025-02-17 16:15:45 -08:00
parent 19e7e1a493
commit 2803976ee5
3 changed files with 11 additions and 12 deletions

View file

@ -124,7 +124,6 @@ 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.SignalServiceGroupV2;
import org.whispersystems.signalservice.api.messages.SignalServicePreview;
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceStoryMessage;
@ -148,9 +147,6 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
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 {
private static final Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
@ -757,6 +753,7 @@ public class ManagerImpl implements Manager {
return sendMessage(messageBuilder, recipients, notifySelf);
}
@Override
public SendMessageResults sendStoryMessage(Message message, RecipientIdentifier.Group idGroup
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
@ -772,8 +769,8 @@ public class ManagerImpl implements Manager {
SignalServiceStoryMessage storyMessage = null;
if (attachments != null && attachments.size() > 0) {
SignalServiceAttachment.Builder attachmentBuilder = new SignalServiceAttachment.Builder().withFileName(attachments.get(0));
storyMessage = SignalServiceStoryMessage.forFileAttachment(profileKey, null, attachmentBuilder.build(), true, bodyRanges);
var attachment = context.getAttachmentHelper().uploadAttachment(attachments.get(0));
storyMessage = SignalServiceStoryMessage.forFileAttachment(profileKey, null, attachment, true, bodyRanges);
} else {
//SignalServiceTextAttachment textBuilder = new SignalServiceTextAttachment.
//storyMessage = SignalServiceStoryMessage.forTextAttachment(profileKey, ssgroup, textBuilder.build(), true, bodyRanges);
@ -1644,5 +1641,4 @@ public class ManagerImpl implements Manager {
account = null;
}
}

View file

@ -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);
}

View file

@ -124,6 +124,13 @@ public class SendCommand implements JsonRpcLocalCommand {
groupIdStrings,
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"));
if (isEndSession) {
final var singleRecipients = recipientIdentifiers.stream()
@ -233,8 +240,6 @@ public class SendCommand implements JsonRpcLocalCommand {
final var editTimestamp = ns.getLong("edit-timestamp");
final boolean story = false;
try {
final var message = new Message(messageText,
attachments,
@ -246,7 +251,7 @@ public class SendCommand implements JsonRpcLocalCommand {
textStyles);
var results = editTimestamp != null
? 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);
outputResult(outputWriter, results);
} catch (AttachmentInvalidException | IOException e) {