Add support for general media attachments to release notes channel messages.

This commit is contained in:
Cody Henthorne
2023-01-03 22:53:58 -05:00
committed by Greyson Parrelli
parent 98dfd5bfbf
commit 43fe789807
3 changed files with 22 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ import org.thoughtcrime.securesms.database.model.StoryType
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
import org.thoughtcrime.securesms.mms.IncomingMediaMessage
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.MediaUtil
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId
@@ -24,29 +25,30 @@ object ReleaseChannel {
recipientId: RecipientId,
body: String,
threadId: Long,
image: String? = null,
imageWidth: Int = 0,
imageHeight: Int = 0,
media: String? = null,
mediaWidth: Int = 0,
mediaHeight: Int = 0,
mediaType: String = "image/webp",
serverUuid: String? = UUID.randomUUID().toString(),
messageRanges: BodyRangeList? = null,
storyType: StoryType = StoryType.NONE
): MessageTable.InsertResult? {
val attachments: Optional<List<SignalServiceAttachment>> = if (image != null) {
val attachments: Optional<List<SignalServiceAttachment>> = if (media != null) {
val attachment = SignalServiceAttachmentPointer(
CDN_NUMBER,
SignalServiceAttachmentRemoteId.from(""),
"image/webp",
mediaType,
null,
Optional.empty(),
Optional.empty(),
imageWidth,
imageHeight,
mediaWidth,
mediaHeight,
Optional.empty(),
Optional.of(image),
false,
Optional.of(media),
false,
false,
MediaUtil.isVideo(mediaType),
Optional.empty(),
Optional.empty(),
System.currentTimeMillis()