mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-07-27 00:39:26 +00:00
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:
parent
2c556f1a8c
commit
4ccad0321f
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user