mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-29 00:03:27 +01:00
Improve attachment field validation.
This commit is contained in:
committed by
Michelle Tang
parent
7ea3679a24
commit
3e8190637c
+10
-3
@@ -7,7 +7,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemo
|
||||
import org.whispersystems.signalservice.internal.push.AttachmentPointer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import okio.ByteString;
|
||||
@@ -18,10 +17,18 @@ public final class AttachmentPointerUtil {
|
||||
}
|
||||
|
||||
public static SignalServiceAttachmentPointer createSignalAttachmentPointer(AttachmentPointer pointer) throws InvalidMessageStructureException {
|
||||
return new SignalServiceAttachmentPointer(Objects.requireNonNull(pointer.cdnNumber),
|
||||
if (pointer.cdnNumber == null) {
|
||||
throw new InvalidMessageStructureException("AttachmentPointer CDN number not set");
|
||||
}
|
||||
|
||||
if (pointer.key == null) {
|
||||
throw new InvalidMessageStructureException("AttachmentPointer key not set");
|
||||
}
|
||||
|
||||
return new SignalServiceAttachmentPointer(pointer.cdnNumber,
|
||||
SignalServiceAttachmentRemoteId.from(pointer),
|
||||
pointer.contentType,
|
||||
Objects.requireNonNull(pointer.key).toByteArray(),
|
||||
pointer.key.toByteArray(),
|
||||
pointer.size != null ? Optional.of(pointer.size) : Optional.empty(),
|
||||
pointer.thumbnail != null ? Optional.of(pointer.thumbnail.toByteArray()): Optional.empty(),
|
||||
pointer.width != null ? pointer.width : 0,
|
||||
|
||||
Reference in New Issue
Block a user