From 71b210792a8fdb973b5b7388c3f5f8364c81060f Mon Sep 17 00:00:00 2001
From: Valere <bill.carson@valrsoft.com>
Date: Thu, 21 Mar 2024 10:16:49 +0100
Subject: [PATCH 1/4] Add new E2E error for expected UTD

---
 schemas/Error.json      | 23 ++++++++++----------
 types/kotlin/Error.kt   | 15 +------------
 types/kotlin2/Error.kt  | 47 +++++++++++++++++++++++++++++++++++++++++
 types/swift/Error.swift | 12 +++++++++++
 4 files changed, 72 insertions(+), 25 deletions(-)

diff --git a/schemas/Error.json b/schemas/Error.json
index 5956f2a..d75df2b 100644
--- a/schemas/Error.json
+++ b/schemas/Error.json
@@ -15,17 +15,18 @@
     },
     "name": {
       "type": "string",
-      "enum": [
-        "UnknownError",
-        "OlmIndexError",
-        "OlmKeysNotSentError",
-        "OlmUnspecifiedError",
-        "VoipUserHangup",
-        "VoipIceFailed",
-        "VoipInviteTimeout",
-        "VoipIceTimeout",
-        "VoipUserMediaFailed",
-        "ToDeviceFailedToDecrypt"
+      "oneOf": [
+        {"const": "OlmIndexError", "description": "E2E domain error. The room key is known but is ratcheted (index > 0)."},
+        {"const": "OlmKeysNotSentError", "description": "E2E domain error. Generic unknown inbound group session error."},
+        {"const": "OlmUnspecifiedError", "description": "E2E domain error. Any other decryption error (missing field, format errors...)."},
+        {"const": "UnknownError", "description": "E2E domain error. Decryption fails due to unknown error."},
+        {"const": "HistoricalMessage", "description": "E2E domain error. Decryption fails for historical message and there is no backup."},
+        {"const": "VoipUserHangup", "description": "VOIP domain error. The user hung up the call."},
+        {"const": "VoipIceFailed", "description": "VOIP domain error. ICE negotiation failed."},
+        {"const": "VoipInviteTimeout", "description": "VOIP domain error. The call invite timed out."},
+        {"const": "VoipIceTimeout", "description": "VOIP domain error. ICE negotiation timed out."},
+        {"const": "VoipUserMediaFailed", "description": "VOIP domain error. The user's media failed to start."},
+        {"const": "ToDeviceFailedToDecrypt", "description": "TO_DEVICE domain error. The to-device message failed to decrypt."}
       ]
     },
     "context": {
diff --git a/types/kotlin/Error.kt b/types/kotlin/Error.kt
index e81a8da..f14cfaa 100644
--- a/types/kotlin/Error.kt
+++ b/types/kotlin/Error.kt
@@ -21,7 +21,7 @@ data class Error (
 
     val domain: Domain,
     val eventName: EventName,
-    val name: Name,
+    val name: String,
 
     /**
      * UTDs can be permanent or temporary. If temporary, this field will contain the time it
@@ -39,16 +39,3 @@ enum class Domain {
 enum class EventName {
     Error
 }
-
-enum class Name {
-    OlmIndexError,
-    OlmKeysNotSentError,
-    OlmUnspecifiedError,
-    ToDeviceFailedToDecrypt,
-    UnknownError,
-    VoipIceFailed,
-    VoipIceTimeout,
-    VoipInviteTimeout,
-    VoipUserHangup,
-    VoipUserMediaFailed
-}
diff --git a/types/kotlin2/Error.kt b/types/kotlin2/Error.kt
index 48e16e5..71c005e 100644
--- a/types/kotlin2/Error.kt
+++ b/types/kotlin2/Error.kt
@@ -54,15 +54,62 @@ data class Error(
     }
 
     enum class Name {
+
+        /**
+         * E2E domain error. Decryption fails for historical message and there
+         * is no backup.
+         */
+        HistoricalMessage,
+
+        /**
+         * E2E domain error. The room key is known but is ratcheted (index > 0).
+         */
         OlmIndexError,
+
+        /**
+         * E2E domain error. Generic unknown inbound group session error.
+         */
         OlmKeysNotSentError,
+
+        /**
+         * E2E domain error. Any other decryption error (missing field, format
+         * errors...).
+         */
         OlmUnspecifiedError,
+
+        /**
+         * TO_DEVICE domain error. The to-device message failed to decrypt.
+         */
         ToDeviceFailedToDecrypt,
+
+        /**
+         * E2E domain error. Decryption fails due to unknown error.
+         */
         UnknownError,
+
+        /**
+         * VOIP domain error. ICE negotiation failed.
+         */
         VoipIceFailed,
+
+        /**
+         * VOIP domain error. ICE negotiation timed out.
+         */
         VoipIceTimeout,
+
+        /**
+         * VOIP domain error. The call invite timed out.
+         */
         VoipInviteTimeout,
+
+        /**
+         * VOIP domain error. The user hung up the call.
+         */
         VoipUserHangup,
+
+        /**
+         * VOIP domain error. The user's media failed to start.
+         */
         VoipUserMediaFailed,
     }
 
diff --git a/types/swift/Error.swift b/types/swift/Error.swift
index a00f4c3..d5de475 100644
--- a/types/swift/Error.swift
+++ b/types/swift/Error.swift
@@ -51,15 +51,27 @@ extension AnalyticsEvent {
         }
 
         public enum Name: String {
+            /// E2E domain error. Decryption fails for historical message and there is no backup.
+            case HistoricalMessage
+            /// E2E domain error. The room key is known but is ratcheted (index > 0).
             case OlmIndexError
+            /// E2E domain error. Generic unknown inbound group session error.
             case OlmKeysNotSentError
+            /// E2E domain error. Any other decryption error (missing field, format errors...).
             case OlmUnspecifiedError
+            /// TO_DEVICE domain error. The to-device message failed to decrypt.
             case ToDeviceFailedToDecrypt
+            /// E2E domain error. Decryption fails due to unknown error.
             case UnknownError
+            /// VOIP domain error. ICE negotiation failed.
             case VoipIceFailed
+            /// VOIP domain error. ICE negotiation timed out.
             case VoipIceTimeout
+            /// VOIP domain error. The call invite timed out.
             case VoipInviteTimeout
+            /// VOIP domain error. The user hung up the call.
             case VoipUserHangup
+            /// VOIP domain error. The user's media failed to start.
             case VoipUserMediaFailed
         }
 

From f708523d103ce783ef7c01b64f0c4232eaf8d6e7 Mon Sep 17 00:00:00 2001
From: Valere <valeref@matrix.org>
Date: Thu, 21 Mar 2024 11:40:11 +0100
Subject: [PATCH 2/4] Update schemas/Error.json

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
---
 schemas/Error.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/schemas/Error.json b/schemas/Error.json
index d75df2b..34007ea 100644
--- a/schemas/Error.json
+++ b/schemas/Error.json
@@ -20,7 +20,7 @@
         {"const": "OlmKeysNotSentError", "description": "E2E domain error. Generic unknown inbound group session error."},
         {"const": "OlmUnspecifiedError", "description": "E2E domain error. Any other decryption error (missing field, format errors...)."},
         {"const": "UnknownError", "description": "E2E domain error. Decryption fails due to unknown error."},
-        {"const": "HistoricalMessage", "description": "E2E domain error. Decryption fails for historical message and there is no backup."},
+        {"const": "HistoricalMessage", "description": "E2E domain error. Decryption failed for a message sent before the device logged in, and key backup is not enabled."},
         {"const": "VoipUserHangup", "description": "VOIP domain error. The user hung up the call."},
         {"const": "VoipIceFailed", "description": "VOIP domain error. ICE negotiation failed."},
         {"const": "VoipInviteTimeout", "description": "VOIP domain error. The call invite timed out."},

From 05ea51ec3e8b0e266b0bb45166b99770ab466e6c Mon Sep 17 00:00:00 2001
From: Valere <valeref@matrix.org>
Date: Thu, 21 Mar 2024 11:40:19 +0100
Subject: [PATCH 3/4] Update schemas/Error.json

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
---
 schemas/Error.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/schemas/Error.json b/schemas/Error.json
index 34007ea..41d3f8a 100644
--- a/schemas/Error.json
+++ b/schemas/Error.json
@@ -19,7 +19,7 @@
         {"const": "OlmIndexError", "description": "E2E domain error. The room key is known but is ratcheted (index > 0)."},
         {"const": "OlmKeysNotSentError", "description": "E2E domain error. Generic unknown inbound group session error."},
         {"const": "OlmUnspecifiedError", "description": "E2E domain error. Any other decryption error (missing field, format errors...)."},
-        {"const": "UnknownError", "description": "E2E domain error. Decryption fails due to unknown error."},
+        {"const": "UnknownError", "description": "E2E domain error. Decryption failed due to unknown error."},
         {"const": "HistoricalMessage", "description": "E2E domain error. Decryption failed for a message sent before the device logged in, and key backup is not enabled."},
         {"const": "VoipUserHangup", "description": "VOIP domain error. The user hung up the call."},
         {"const": "VoipIceFailed", "description": "VOIP domain error. ICE negotiation failed."},

From 9e1c84b492aeff9ecc7029789cd4562737ab4f61 Mon Sep 17 00:00:00 2001
From: Valere <bill.carson@valrsoft.com>
Date: Thu, 21 Mar 2024 13:14:37 +0100
Subject: [PATCH 4/4] fix domain  + udapte comments

---
 schemas/Error.json      | 10 +++++-----
 types/kotlin2/Error.kt  | 13 +++++++------
 types/swift/Error.swift | 10 +++++-----
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/schemas/Error.json b/schemas/Error.json
index 41d3f8a..8164899 100644
--- a/schemas/Error.json
+++ b/schemas/Error.json
@@ -16,11 +16,11 @@
     "name": {
       "type": "string",
       "oneOf": [
-        {"const": "OlmIndexError", "description": "E2E domain error. The room key is known but is ratcheted (index > 0)."},
-        {"const": "OlmKeysNotSentError", "description": "E2E domain error. Generic unknown inbound group session error."},
-        {"const": "OlmUnspecifiedError", "description": "E2E domain error. Any other decryption error (missing field, format errors...)."},
-        {"const": "UnknownError", "description": "E2E domain error. Decryption failed due to unknown error."},
-        {"const": "HistoricalMessage", "description": "E2E domain error. Decryption failed for a message sent before the device logged in, and key backup is not enabled."},
+        {"const": "OlmIndexError", "description": "E2EE domain error. The room key is known but is ratcheted (index > 0)."},
+        {"const": "OlmKeysNotSentError", "description": "E2EE domain error. Generic unknown inbound group session error."},
+        {"const": "OlmUnspecifiedError", "description": "E2EE domain error. Any other decryption error (missing field, format errors...)."},
+        {"const": "UnknownError", "description": "E2EE domain error. Decryption failed due to unknown error."},
+        {"const": "HistoricalMessage", "description": "E2EE domain error. Decryption failed for a message sent before the device logged in, and key backup is not enabled."},
         {"const": "VoipUserHangup", "description": "VOIP domain error. The user hung up the call."},
         {"const": "VoipIceFailed", "description": "VOIP domain error. ICE negotiation failed."},
         {"const": "VoipInviteTimeout", "description": "VOIP domain error. The call invite timed out."},
diff --git a/types/kotlin2/Error.kt b/types/kotlin2/Error.kt
index 71c005e..77ce3f1 100644
--- a/types/kotlin2/Error.kt
+++ b/types/kotlin2/Error.kt
@@ -56,23 +56,24 @@ data class Error(
     enum class Name {
 
         /**
-         * E2E domain error. Decryption fails for historical message and there
-         * is no backup.
+         * E2EE domain error. Decryption failed for a message sent before the
+         * device logged in, and key backup is not enabled.
          */
         HistoricalMessage,
 
         /**
-         * E2E domain error. The room key is known but is ratcheted (index > 0).
+         * E2EE domain error. The room key is known but is ratcheted (index >
+         * 0).
          */
         OlmIndexError,
 
         /**
-         * E2E domain error. Generic unknown inbound group session error.
+         * E2EE domain error. Generic unknown inbound group session error.
          */
         OlmKeysNotSentError,
 
         /**
-         * E2E domain error. Any other decryption error (missing field, format
+         * E2EE domain error. Any other decryption error (missing field, format
          * errors...).
          */
         OlmUnspecifiedError,
@@ -83,7 +84,7 @@ data class Error(
         ToDeviceFailedToDecrypt,
 
         /**
-         * E2E domain error. Decryption fails due to unknown error.
+         * E2EE domain error. Decryption failed due to unknown error.
          */
         UnknownError,
 
diff --git a/types/swift/Error.swift b/types/swift/Error.swift
index d5de475..fef8ded 100644
--- a/types/swift/Error.swift
+++ b/types/swift/Error.swift
@@ -51,17 +51,17 @@ extension AnalyticsEvent {
         }
 
         public enum Name: String {
-            /// E2E domain error. Decryption fails for historical message and there is no backup.
+            /// E2EE domain error. Decryption failed for a message sent before the device logged in, and key backup is not enabled.
             case HistoricalMessage
-            /// E2E domain error. The room key is known but is ratcheted (index > 0).
+            /// E2EE domain error. The room key is known but is ratcheted (index > 0).
             case OlmIndexError
-            /// E2E domain error. Generic unknown inbound group session error.
+            /// E2EE domain error. Generic unknown inbound group session error.
             case OlmKeysNotSentError
-            /// E2E domain error. Any other decryption error (missing field, format errors...).
+            /// E2EE domain error. Any other decryption error (missing field, format errors...).
             case OlmUnspecifiedError
             /// TO_DEVICE domain error. The to-device message failed to decrypt.
             case ToDeviceFailedToDecrypt
-            /// E2E domain error. Decryption fails due to unknown error.
+            /// E2EE domain error. Decryption failed due to unknown error.
             case UnknownError
             /// VOIP domain error. ICE negotiation failed.
             case VoipIceFailed