mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
fix send text message to open group
This commit is contained in:
parent
d9eaedd6ae
commit
8acbb3c366
@ -425,6 +425,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
||||||
LokiAPIDatabaseProtocol apiDB = DatabaseFactory.getLokiAPIDatabase(this);
|
LokiAPIDatabaseProtocol apiDB = DatabaseFactory.getLokiAPIDatabase(this);
|
||||||
FileServerAPI.Companion.configure(userPublicKey, userPrivateKey, apiDB);
|
FileServerAPI.Companion.configure(userPublicKey, userPrivateKey, apiDB);
|
||||||
|
org.session.libsession.messaging.fileserver.FileServerAPI.Companion.configure(userPublicKey, userPrivateKey, apiDB);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 database = DatabaseFactory.getMmsSmsDatabase(context)
|
||||||
val messageRecord = database.getMessageFor(messageID) ?: return
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
||||||
if (messageRecord.isMms) {
|
if (messageRecord.isMms) {
|
||||||
val mmsDatabase = DatabaseFactory.getMmsDatabase(context)
|
val mmsDatabase = DatabaseFactory.getMmsDatabase(context)
|
||||||
mmsDatabase.markAsSentFailed(messageID)
|
mmsDatabase.markAsSentFailed(messageRecord.getId())
|
||||||
} else {
|
} else {
|
||||||
val smsDatabase = DatabaseFactory.getSmsDatabase(context)
|
val smsDatabase = DatabaseFactory.getSmsDatabase(context)
|
||||||
smsDatabase.markAsSentFailed(messageID)
|
smsDatabase.markAsSentFailed(messageRecord.getId())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ interface StorageProtocol {
|
|||||||
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long)
|
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long)
|
||||||
fun markAsSent(timestamp: Long, author: String)
|
fun markAsSent(timestamp: Long, author: String)
|
||||||
fun markUnidentified(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
|
// Closed Groups
|
||||||
fun getGroup(groupID: String): GroupRecord?
|
fun getGroup(groupID: String): GroupRecord?
|
||||||
|
@ -19,7 +19,8 @@ sealed class Destination {
|
|||||||
val groupPublicKey = GroupUtil.getDecodedGroupID(groupID)
|
val groupPublicKey = GroupUtil.getDecodedGroupID(groupID)
|
||||||
return ClosedGroup(groupPublicKey)
|
return ClosedGroup(groupPublicKey)
|
||||||
} else if (address.isOpenGroup) {
|
} 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)
|
return OpenGroup(openGroup.channel, openGroup.server)
|
||||||
} else {
|
} else {
|
||||||
throw Exception("TODO: Handle legacy closed groups.")
|
throw Exception("TODO: Handle legacy closed groups.")
|
||||||
|
@ -209,8 +209,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
format.timeZone = TimeZone.getTimeZone("GMT")
|
format.timeZone = TimeZone.getTimeZone("GMT")
|
||||||
val dateAsString = data["created_at"] as String
|
val dateAsString = data["created_at"] as String
|
||||||
val timestamp = format.parse(dateAsString).time
|
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)
|
OpenGroupMessage(serverID, userKeyPair.first, userDisplayName, text, timestamp, openGroupMessageType, message.quote, message.attachments, null, signedMessage.signature, timestamp)
|
||||||
message
|
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.d("Loki", "Couldn't parse message for open group with ID: $channel on server: $server.")
|
Log.d("Loki", "Couldn't parse message for open group with ID: $channel on server: $server.")
|
||||||
throw exception
|
throw exception
|
||||||
|
@ -68,7 +68,7 @@ object MessageSender {
|
|||||||
attachment.caption = signalAttachment.caption
|
attachment.caption = signalAttachment.caption
|
||||||
attachment.contentType = signalAttachment.contentType
|
attachment.contentType = signalAttachment.contentType
|
||||||
attachment.digest = signalAttachment.digest
|
attachment.digest = signalAttachment.digest
|
||||||
attachment.key = Base64.decode(signalAttachment.key)
|
attachment.key = Base64.decode(signalAttachment.key ?: "")
|
||||||
attachment.sizeInBytes = signalAttachment.size.toInt()
|
attachment.sizeInBytes = signalAttachment.size.toInt()
|
||||||
attachment.url = signalAttachment.url
|
attachment.url = signalAttachment.url
|
||||||
attachment.size = Size(signalAttachment.width, signalAttachment.height)
|
attachment.size = Size(signalAttachment.width, signalAttachment.height)
|
||||||
@ -298,8 +298,7 @@ object MessageSender {
|
|||||||
|
|
||||||
fun handleFailedMessageSend(message: Message, error: Exception) {
|
fun handleFailedMessageSend(message: Message, error: Exception) {
|
||||||
val storage = MessagingConfiguration.shared.storage
|
val storage = MessagingConfiguration.shared.storage
|
||||||
val messageId = storage.getMessageIdInDatabase(message.sentTimestamp!!, message.sender!!) ?: return
|
storage.setErrorMessage(message.sentTimestamp!!, message.sender!!, error)
|
||||||
storage.setErrorMessage(messageId, error)
|
|
||||||
SnodeConfiguration.shared.broadcaster.broadcast("messageFailed", message.sentTimestamp!!)
|
SnodeConfiguration.shared.broadcaster.broadcast("messageFailed", message.sentTimestamp!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user