Validate story attachment MIME type and fix D-Bus stub

- Reject non-image/video attachments before uploading, since stories
  only support image and video content
- Change DbusManagerImpl.sendStory to throw UnsupportedOperationException
  to match the pattern used by all other unimplemented D-Bus methods
This commit is contained in:
Tony Cebzanov 2026-07-09 02:18:53 -04:00
parent 2c556f1a8c
commit 4ccad0321f
2 changed files with 7 additions and 1 deletions

View File

@ -835,6 +835,12 @@ public class ManagerImpl implements Manager {
String attachment,
boolean allowsReplies
) throws IOException, AttachmentInvalidException {
final var file = new File(attachment);
final var mimeType = MimeUtils.getFileMimeType(file);
if (mimeType.isEmpty() || (!mimeType.get().startsWith("image/") && !mimeType.get().startsWith("video/"))) {
throw new AttachmentInvalidException(attachment,
new IOException("Stories only support image and video attachments"));
}
final var uploadedAttachment = context.getAttachmentHelper().uploadAttachment(attachment);
final var storyMessage = SignalServiceStoryMessage.forFileAttachment(account.getProfileKey().serialize(),
null,

View File

@ -544,7 +544,7 @@ public class DbusManagerImpl implements Manager {
@Override
public SendMessageResults sendStory(String attachment, boolean allowsReplies) {
return new SendMessageResults(0, Map.of());
throw new UnsupportedOperationException();
}
@Override