diff --git a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java index d4a6da8f6f..b9051c0bef 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java @@ -425,6 +425,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize(); LokiAPIDatabaseProtocol apiDB = DatabaseFactory.getLokiAPIDatabase(this); FileServerAPI.Companion.configure(userPublicKey, userPrivateKey, apiDB); + org.session.libsession.messaging.fileserver.FileServerAPI.Companion.configure(userPublicKey, userPrivateKey, apiDB); return true; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 2addeff617..91cec2c2fd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -354,15 +354,15 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, } } - override fun setErrorMessage(messageID: Long, error: Exception) { + override fun setErrorMessage(timestamp: Long, author: String, error: Exception) { val database = DatabaseFactory.getMmsSmsDatabase(context) - val messageRecord = database.getMessageFor(messageID) ?: return + val messageRecord = database.getMessageFor(timestamp, author) ?: return if (messageRecord.isMms) { val mmsDatabase = DatabaseFactory.getMmsDatabase(context) - mmsDatabase.markAsSentFailed(messageID) + mmsDatabase.markAsSentFailed(messageRecord.getId()) } else { val smsDatabase = DatabaseFactory.getSmsDatabase(context) - smsDatabase.markAsSentFailed(messageID) + smsDatabase.markAsSentFailed(messageRecord.getId()) } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/StorageProtocol.kt b/libsession/src/main/java/org/session/libsession/messaging/StorageProtocol.kt index bd94250598..a7bb7e0dc1 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/StorageProtocol.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/StorageProtocol.kt @@ -97,7 +97,7 @@ interface StorageProtocol { fun setOpenGroupServerMessageID(messageID: Long, serverID: Long) fun markAsSent(timestamp: Long, author: String) fun markUnidentified(timestamp: Long, author: String) - fun setErrorMessage(messageID: Long, error: Exception) + fun setErrorMessage(timestamp: Long, author: String, error: Exception) // Closed Groups fun getGroup(groupID: String): GroupRecord? diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/Destination.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/Destination.kt index 03fb189203..3f92058380 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/Destination.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/Destination.kt @@ -19,7 +19,8 @@ sealed class Destination { val groupPublicKey = GroupUtil.getDecodedGroupID(groupID) return ClosedGroup(groupPublicKey) } else if (address.isOpenGroup) { - val openGroup = MessagingConfiguration.shared.storage.getOpenGroup(address.contactIdentifier())!! + val threadID = MessagingConfiguration.shared.storage.getThreadID(address.contactIdentifier())!! + val openGroup = MessagingConfiguration.shared.storage.getOpenGroup(threadID)!! return OpenGroup(openGroup.channel, openGroup.server) } else { throw Exception("TODO: Handle legacy closed groups.") diff --git a/libsession/src/main/java/org/session/libsession/messaging/opengroups/OpenGroupAPI.kt b/libsession/src/main/java/org/session/libsession/messaging/opengroups/OpenGroupAPI.kt index 61f1ad1df1..f98703cc2a 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/opengroups/OpenGroupAPI.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/opengroups/OpenGroupAPI.kt @@ -209,8 +209,7 @@ object OpenGroupAPI: DotNetAPI() { format.timeZone = TimeZone.getTimeZone("GMT") val dateAsString = data["created_at"] as String val timestamp = format.parse(dateAsString).time - @Suppress("NAME_SHADOWING") val message = OpenGroupMessage(serverID, userKeyPair.first, userDisplayName, text, timestamp, openGroupMessageType, message.quote, message.attachments, null, signedMessage.signature, timestamp) - message + OpenGroupMessage(serverID, userKeyPair.first, userDisplayName, text, timestamp, openGroupMessageType, message.quote, message.attachments, null, signedMessage.signature, timestamp) } catch (exception: Exception) { Log.d("Loki", "Couldn't parse message for open group with ID: $channel on server: $server.") throw exception diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt index b105d1fa6f..55bbd6afa9 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt @@ -68,7 +68,7 @@ object MessageSender { attachment.caption = signalAttachment.caption attachment.contentType = signalAttachment.contentType attachment.digest = signalAttachment.digest - attachment.key = Base64.decode(signalAttachment.key) + attachment.key = Base64.decode(signalAttachment.key ?: "") attachment.sizeInBytes = signalAttachment.size.toInt() attachment.url = signalAttachment.url attachment.size = Size(signalAttachment.width, signalAttachment.height) @@ -298,8 +298,7 @@ object MessageSender { fun handleFailedMessageSend(message: Message, error: Exception) { val storage = MessagingConfiguration.shared.storage - val messageId = storage.getMessageIdInDatabase(message.sentTimestamp!!, message.sender!!) ?: return - storage.setErrorMessage(messageId, error) + storage.setErrorMessage(message.sentTimestamp!!, message.sender!!, error) SnodeConfiguration.shared.broadcaster.broadcast("messageFailed", message.sentTimestamp!!) }