mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-02 14:35:21 +00:00
Fix attachment pointer conversion
This commit is contained in:
parent
361be28223
commit
9074355b4e
@ -230,12 +230,12 @@ fun DatabaseAttachment.toAttachmentStream(context: Context): SessionServiceAttac
|
|||||||
|
|
||||||
fun DatabaseAttachment.toSignalAttachmentPointer(): SignalServiceAttachmentPointer? {
|
fun DatabaseAttachment.toSignalAttachmentPointer(): SignalServiceAttachmentPointer? {
|
||||||
if (TextUtils.isEmpty(location)) { return null }
|
if (TextUtils.isEmpty(location)) { return null }
|
||||||
if (TextUtils.isEmpty(key)) { return null }
|
// `key` can be empty in an open group context (no encryption means no encryption key)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val id: Long = location!!.toLong()
|
val id = location!!.toLong()
|
||||||
val key: ByteArray = Base64.decode(key!!)
|
val key = Base64.decode(key!!)
|
||||||
SignalServiceAttachmentPointer(id,
|
SignalServiceAttachmentPointer(
|
||||||
|
id,
|
||||||
contentType,
|
contentType,
|
||||||
key,
|
key,
|
||||||
Optional.of(Util.toIntExact(size)),
|
Optional.of(Util.toIntExact(size)),
|
||||||
@ -246,7 +246,8 @@ fun DatabaseAttachment.toSignalAttachmentPointer(): SignalServiceAttachmentPoint
|
|||||||
Optional.fromNullable(fileName),
|
Optional.fromNullable(fileName),
|
||||||
isVoiceNote,
|
isVoiceNote,
|
||||||
Optional.fromNullable(caption),
|
Optional.fromNullable(caption),
|
||||||
url)
|
url
|
||||||
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user