mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 10:05:15 +00:00
make error description show in the message detail activity
This commit is contained in:
parent
2e65077b3a
commit
95646ed04e
@ -44,6 +44,7 @@ import org.session.libsession.messaging.messages.signal.IncomingGroupMessage
|
||||
import org.session.libsession.messaging.messages.signal.IncomingTextMessage
|
||||
import org.session.libsession.messaging.messages.signal.OutgoingTextMessage
|
||||
import org.session.libsession.utilities.preferences.ProfileKeyUtil
|
||||
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
||||
|
||||
class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), StorageProtocol {
|
||||
override fun getUserPublicKey(): String? {
|
||||
@ -368,6 +369,11 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
val smsDatabase = DatabaseFactory.getSmsDatabase(context)
|
||||
smsDatabase.markAsSentFailed(messageRecord.getId())
|
||||
}
|
||||
if (error.localizedMessage != null) {
|
||||
DatabaseFactory.getLokiMessageDatabase(context).setErrorMessage(messageRecord.getId(), error.localizedMessage!!)
|
||||
} else {
|
||||
DatabaseFactory.getLokiMessageDatabase(context).setErrorMessage(messageRecord.getId(), error.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getGroup(groupID: String): GroupRecord? {
|
||||
|
@ -17,7 +17,7 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
|
||||
private val MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024
|
||||
|
||||
// Error
|
||||
internal sealed class Error(val description: String) : Exception() {
|
||||
internal sealed class Error(val description: String) : Exception(description) {
|
||||
object NoAttachment : Error("No such attachment.")
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
|
||||
override var failureCount: Int = 0
|
||||
|
||||
// Error
|
||||
internal sealed class Error(val description: String) : Exception() {
|
||||
internal sealed class Error(val description: String) : Exception(description) {
|
||||
object NoAttachment : Error("No such attachment.")
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ object MessageReceiver {
|
||||
|
||||
private val lastEncryptionKeyPairRequest = mutableMapOf<String, Long>()
|
||||
|
||||
internal sealed class Error(val description: String) : Exception() {
|
||||
internal sealed class Error(val description: String) : Exception(description) {
|
||||
object DuplicateMessage: Error("Duplicate message.")
|
||||
object InvalidMessage: Error("Invalid message.")
|
||||
object UnknownMessage: Error("Unknown message type.")
|
||||
|
@ -34,7 +34,7 @@ import org.session.libsignal.utilities.logging.Log
|
||||
object MessageSender {
|
||||
|
||||
// Error
|
||||
sealed class Error(val description: String) : Exception() {
|
||||
sealed class Error(val description: String) : Exception(description) {
|
||||
object InvalidMessage : Error("Invalid message.")
|
||||
object ProtoConversionFailed : Error("Couldn't convert message to proto.")
|
||||
object ProofOfWorkCalculationFailed : Error("Proof of work calculation failed.")
|
||||
@ -202,6 +202,11 @@ object MessageSender {
|
||||
val preconditionFailure = Exception("Destination should not be contacts or closed groups!")
|
||||
message.sentTimestamp ?: run { message.sentTimestamp = System.currentTimeMillis() }
|
||||
message.sender = storage.getUserPublicKey()
|
||||
// Set the failure handler (need it here already for precondition failure handling)
|
||||
fun handleFailure(error: Exception) {
|
||||
handleFailedMessageSend(message, error)
|
||||
deferred.reject(error)
|
||||
}
|
||||
try {
|
||||
val server: String
|
||||
val channel: Long
|
||||
@ -214,19 +219,12 @@ object MessageSender {
|
||||
channel = destination.channel
|
||||
}
|
||||
}
|
||||
// Set the failure handler (need it here already for precondition failure handling)
|
||||
fun handleFailure(error: Exception) {
|
||||
handleFailedMessageSend(message, error)
|
||||
deferred.reject(error)
|
||||
}
|
||||
// Validate the message
|
||||
if (message !is VisibleMessage || !message.isValid()) {
|
||||
handleFailure(Error.InvalidMessage)
|
||||
throw Error.InvalidMessage
|
||||
}
|
||||
// Convert the message to an open group message
|
||||
val openGroupMessage = OpenGroupMessage.from(message, server) ?: kotlin.run {
|
||||
handleFailure(Error.InvalidMessage)
|
||||
throw Error.InvalidMessage
|
||||
}
|
||||
// Send the result
|
||||
@ -238,7 +236,7 @@ object MessageSender {
|
||||
handleFailure(it)
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
deferred.reject(exception)
|
||||
handleFailure(exception)
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ open class DotNetAPI {
|
||||
internal enum class HTTPVerb { GET, PUT, POST, DELETE, PATCH }
|
||||
|
||||
// Error
|
||||
internal sealed class Error(val description: String) : Exception() {
|
||||
internal sealed class Error(val description: String) : Exception(description) {
|
||||
object Generic : Error("An error occurred.")
|
||||
object InvalidURL : Error("Invalid URL.")
|
||||
object ParsingFailed : Error("Invalid file server response.")
|
||||
|
@ -10,7 +10,7 @@ import java.security.SecureRandom
|
||||
object MessageWrapper {
|
||||
|
||||
// region Types
|
||||
sealed class Error(val description: String) : Exception() {
|
||||
sealed class Error(val description: String) : Exception(description) {
|
||||
object FailedToWrapData : Error("Failed to wrap data.")
|
||||
object FailedToWrapMessageInEnvelope : Error("Failed to wrap message in envelope.")
|
||||
object FailedToWrapEnvelopeInWebSocketMessage : Error("Failed to wrap envelope in web socket message.")
|
||||
|
@ -45,7 +45,7 @@ object SnodeAPI {
|
||||
internal var powDifficulty = 1
|
||||
|
||||
// Error
|
||||
internal sealed class Error(val description: String) : Exception() {
|
||||
internal sealed class Error(val description: String) : Exception(description) {
|
||||
object Generic : Error("An error occurred.")
|
||||
object ClockOutOfSync : Error("The user's clock is out of sync with the service node network.")
|
||||
object RandomSnodePoolUpdatingFailed : Error("Failed to update random service node pool.")
|
||||
|
@ -50,7 +50,7 @@ class MnemonicCodec(private val loadFileContents: (String) -> String) {
|
||||
}
|
||||
}
|
||||
|
||||
sealed class DecodingError(val description: String) : Exception() {
|
||||
sealed class DecodingError(val description: String) : Exception(description) {
|
||||
object Generic : DecodingError("Something went wrong. Please check your mnemonic and try again.")
|
||||
object InputTooShort : DecodingError("Looks like you didn't enter enough words. Please check your mnemonic and try again.")
|
||||
object MissingLastWord : DecodingError("You seem to be missing the last word of your mnemonic. Please check what you entered and try again.")
|
||||
|
Loading…
Reference in New Issue
Block a user