From effd37402a9b0ff7669f9c918ca203b48756b8f5 Mon Sep 17 00:00:00 2001
From: JRoberts <8711996+jr-simplex@users.noreply.github.com>
Date: Thu, 21 Apr 2022 11:50:24 +0400
Subject: [PATCH] SMP AUTH error processing and descriptions (#544)
* SMP AUTH error descriptions
* change text
* android error description
* Update apps/android/app/src/main/res/values/strings.xml
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
* Update apps/android/app/src/main/res/values-ru/strings.xml
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
* fix translations
* Apply suggestions from code review
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
---
.../main/java/chat/simplex/app/model/SimpleXAPI.kt | 9 +++++++++
apps/android/app/src/main/res/values-ru/strings.xml | 2 ++
apps/android/app/src/main/res/values/strings.xml | 2 ++
apps/ios/Shared/Model/SimpleXAPI.swift | 6 ++++++
.../en.xcloc/Localized Contents/en.xliff | 12 ++++++++++++
.../ru.xcloc/Localized Contents/ru.xliff | 12 ++++++++++++
apps/ios/ru.lproj/Localizable.strings | 6 ++++++
src/Simplex/Chat/View.hs | 5 ++++-
tests/ChatTests.hs | 2 +-
9 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
index 1e7afd0875..14ed6cd63e 100644
--- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
+++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
@@ -223,6 +223,15 @@ open class ChatController(private val ctrl: ChatCtrl, private val ntfManager: Nt
)
return false
}
+ r is CR.ChatCmdError && r.chatError is ChatError.ChatErrorAgent
+ && r.chatError.agentError is AgentErrorType.SMP
+ && r.chatError.agentError.smpErr is SMPErrorType.AUTH -> {
+ AlertManager.shared.showAlertMsg(
+ generalGetString(R.string.connection_error_auth),
+ generalGetString(R.string.connection_error_auth_desc)
+ )
+ return false
+ }
else -> {
apiErrorAlert("apiConnect", "Connection error", r)
return false
diff --git a/apps/android/app/src/main/res/values-ru/strings.xml b/apps/android/app/src/main/res/values-ru/strings.xml
index 00e966e7ce..ddabcdea50 100644
--- a/apps/android/app/src/main/res/values-ru/strings.xml
+++ b/apps/android/app/src/main/res/values-ru/strings.xml
@@ -33,6 +33,8 @@
Вы уже соединены с %1$s! через эту ссылку.Ошибка в ссылке контактаПожалуйста, проверьте, что вы использовали правильную ссылку, или попросите ваш контакт отправить вам новую.
+ Ошибка соединения (AUTH)
+ Возможно, ваш контакт удалил ссылку, или она уже была использована. Если это не так, то это может быть ошибкой - пожалуйста, сообщите нам об этом.\nЧтобы установить соединение, попросите ваш контакт создать еще одну ссылку и проверьте ваше соединение с сетью.Невозможно удалить контакт!Контакт %1$s! не может быть удален, так как является членом групп(ы) %2$s.Мгновенные уведомления
diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml
index 29b95f2921..30ed858e2c 100644
--- a/apps/android/app/src/main/res/values/strings.xml
+++ b/apps/android/app/src/main/res/values/strings.xml
@@ -33,6 +33,8 @@
You are already connected to %1$s! via this link.Invalid connection linkPlease check that you used the correct link or ask your contact to send you another one.
+ Connection error (AUTH)
+ Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.\nTo connect, please ask your contact to create another connection link and check that you have a stable network connection.Can\'t delete contact!Contact %1$s! cannot be deleted, they are a member of the group(s) %2$s.Instant notifications
diff --git a/apps/ios/Shared/Model/SimpleXAPI.swift b/apps/ios/Shared/Model/SimpleXAPI.swift
index e173f865cd..14a52c7e02 100644
--- a/apps/ios/Shared/Model/SimpleXAPI.swift
+++ b/apps/ios/Shared/Model/SimpleXAPI.swift
@@ -492,6 +492,12 @@ func apiConnect(connReq: String) async throws -> Bool {
message: "Please check your network connection and try again."
)
return false
+ case .chatCmdError(.errorAgent(.SMP(.AUTH))):
+ am.showAlertMsg(
+ title: "Connection error (AUTH)",
+ message: "Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.\nTo connect, please ask your contact to create another connection link and check that you have a stable network connection."
+ )
+ return false
default: throw r
}
}
diff --git a/apps/ios/SimpleX Localizations/en.xcloc/Localized Contents/en.xliff b/apps/ios/SimpleX Localizations/en.xcloc/Localized Contents/en.xliff
index d4c03f1dfa..3c41816622 100644
--- a/apps/ios/SimpleX Localizations/en.xcloc/Localized Contents/en.xliff
+++ b/apps/ios/SimpleX Localizations/en.xcloc/Localized Contents/en.xliff
@@ -195,6 +195,11 @@
Connection errorNo comment provided by engineer.
+
+ Connection error (AUTH)
+ Connection error (AUTH)
+ No comment provided by engineer.
+ Connection requestConnection request
@@ -587,6 +592,13 @@ to scan from the app
Unexpected error: %@No comment provided by engineer.
+
+ Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.
+To connect, please ask your contact to create another connection link and check that you have a stable network connection.
+ Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.
+To connect, please ask your contact to create another connection link and check that you have a stable network connection.
+ No comment provided by engineer.
+ Use SimpleX Chat servers?Use SimpleX Chat servers?
diff --git a/apps/ios/SimpleX Localizations/ru.xcloc/Localized Contents/ru.xliff b/apps/ios/SimpleX Localizations/ru.xcloc/Localized Contents/ru.xliff
index 53bebfcc1d..377d0b05ec 100644
--- a/apps/ios/SimpleX Localizations/ru.xcloc/Localized Contents/ru.xliff
+++ b/apps/ios/SimpleX Localizations/ru.xcloc/Localized Contents/ru.xliff
@@ -195,6 +195,11 @@
Ошибка соединенияNo comment provided by engineer.
+
+ Connection error (AUTH)
+ Ошибка соединения (AUTH)
+ No comment provided by engineer.
+ Connection requestЗапрос на соединение
@@ -586,6 +591,13 @@ to scan from the app
Неожиданная ошибка: %@No comment provided by engineer.
+
+ Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.
+To connect, please ask your contact to create another connection link and check that you have a stable network connection.
+ Возможно, ваш контакт удалил ссылку, или она уже была использована. Если это не так, то это может быть ошибкой - пожалуйста, сообщите нам об этом.
+Чтобы установить соединение, попросите ваш контакт создать еще одну ссылку и проверьте ваше соединение с сетью.
+ No comment provided by engineer.
+ Use SimpleX Chat servers?Использовать серверы предосталенные SimpleX Chat?
diff --git a/apps/ios/ru.lproj/Localizable.strings b/apps/ios/ru.lproj/Localizable.strings
index 443dc446bc..e5ec985260 100644
--- a/apps/ios/ru.lproj/Localizable.strings
+++ b/apps/ios/ru.lproj/Localizable.strings
@@ -142,6 +142,9 @@
/* No comment provided by engineer. */
"Connection error" = "Ошибка соединения";
+/* No comment provided by engineer. */
+"Connection error (AUTH)" = "Ошибка соединения (AUTH)";
+
/* No comment provided by engineer. */
"Connection request" = "Запрос на соединение";
@@ -388,6 +391,9 @@
/* No comment provided by engineer. */
"Unexpected error: %@" = "Неожиданная ошибка: %@";
+/* No comment provided by engineer. */
+"Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.\nTo connect, please ask your contact to create another connection link and check that you have a stable network connection." = "Возможно, ваш контакт удалил ссылку, или она уже была использована. Если это не так, то это может быть ошибкой - пожалуйста, сообщите нам об этом.\nЧтобы установить соединение, попросите ваш контакт создать еще одну ссылку и проверьте ваше соединение с сетью.";
+
/* No comment provided by engineer. */
"Use SimpleX Chat servers?" = "Использовать серверы предосталенные SimpleX Chat?";
diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs
index 2d1132f4d1..e8736640a6 100644
--- a/src/Simplex/Chat/View.hs
+++ b/src/Simplex/Chat/View.hs
@@ -654,7 +654,10 @@ viewChatError = \case
SEQuotedChatItemNotFound -> ["message not found - reply is not sent"]
e -> ["chat db error: " <> sShow e]
ChatErrorAgent err -> case err of
- SMP SMP.AUTH -> ["error: this connection is deleted"]
+ SMP SMP.AUTH ->
+ [ "error: connection authorization failed - this could happen if connection was deleted,\
+ \ secured with different credentials, or due to a bug - please re-create the connection"
+ ]
e -> ["smp agent error: " <> sShow e]
where
fileNotFound fileId = ["file " <> sShow fileId <> " not found"]
diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs
index dc49a12808..6bdd2e86de 100644
--- a/tests/ChatTests.hs
+++ b/tests/ChatTests.hs
@@ -1694,7 +1694,7 @@ testRejectContactAndDeleteUserContact = testChat3 aliceProfile bobProfile cathPr
alice <## "To create a new chat address use /ad"
cath ##> ("/c " <> cLink)
- cath <## "error: this connection is deleted"
+ cath <## "error: connection authorization failed - this could happen if connection was deleted, secured with different credentials, or due to a bug - please re-create the connection"
testDeleteConnectionRequests :: IO ()
testDeleteConnectionRequests = testChat3 aliceProfile bobProfile cathProfile $