mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-09-22 06:29:04 +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,
|
String attachment,
|
||||||
boolean allowsReplies
|
boolean allowsReplies
|
||||||
) throws IOException, AttachmentInvalidException {
|
) 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 uploadedAttachment = context.getAttachmentHelper().uploadAttachment(attachment);
|
||||||
final var storyMessage = SignalServiceStoryMessage.forFileAttachment(account.getProfileKey().serialize(),
|
final var storyMessage = SignalServiceStoryMessage.forFileAttachment(account.getProfileKey().serialize(),
|
||||||
null,
|
null,
|
||||||
|
|||||||
@ -544,7 +544,7 @@ public class DbusManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendStory(String attachment, boolean allowsReplies) {
|
public SendMessageResults sendStory(String attachment, boolean allowsReplies) {
|
||||||
return new SendMessageResults(0, Map.of());
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user