Skip to content

Commit 019b3ca

Browse files
authored
Merge pull request #11 from MangoCubes/dev
Fixed a bug where messages are not sent if profile picture is not set
2 parents 730d2fb + 11ba3d8 commit 019b3ca

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/src/main/java/ch/skew/remotrix/works/SendMsgWorker.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,15 @@ class SendMsgWorker(
209209
if(current == senderNumber) {
210210
val nameIndex = contacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)
211211
val pictureIndex = contacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI)
212-
picUri = Uri.parse(contacts.getString(pictureIndex))
213-
roomName = contacts.getString(nameIndex)
212+
if(pictureIndex >= 0) {
213+
val uri = contacts.getString(pictureIndex)
214+
if (uri !== null) picUri = Uri.parse(uri)
215+
}
216+
if(nameIndex >= 0){
217+
val name = contacts.getString(nameIndex)
218+
if (name !== null) roomName = name
219+
}
220+
214221
break
215222
}
216223
}
@@ -245,7 +252,7 @@ class SendMsgWorker(
245252
val length = stream.available()
246253
client.api.media.upload(
247254
Media(
248-
ByteReadChannel(stream.readAllBytes()),
255+
ByteReadChannel(stream.readBytes()),
249256
contentLength = length.toLong(),
250257
filename = roomName,
251258
contentType = ContentType("image", "jpeg")

0 commit comments

Comments
 (0)