Philipp Hörist pushed to branch storage at gajim / gajim


Commits:
eedcc108 by Philipp Hörist at 2023-06-20T21:01:45+02:00
Fix errors

- - - - -


4 changed files:

- gajim/common/events.py
- gajim/common/modules/message.py
- gajim/common/storage/archive2/statements.py
- gajim/common/storage/archive2/structs.py


Changes:

=====================================
gajim/common/events.py
=====================================
@@ -454,7 +454,6 @@ class MessageError(ApplicationEvent):
     name: str = field(init=False, default='message-error')
     account: str
     jid: JID
-    room_jid: str
     message_id: str
     error: Any
 


=====================================
gajim/common/modules/message.py
=====================================
@@ -38,6 +38,7 @@
 from gajim.common.storage.archive2.const import SecLabelType
 from gajim.common.storage.archive2.structs import DbInsertCorrectionsRowData
 from gajim.common.storage.archive2.structs import DbInsertEncryptionRowData
+from gajim.common.storage.archive2.structs import DbInsertErrorsRowData
 from gajim.common.storage.archive2.structs import DbInsertMessagesRowData
 from gajim.common.storage.archive2.structs import DbInsertOOBRowData
 from gajim.common.storage.archive2.structs import DbInsertRowDataBase
@@ -253,23 +254,26 @@ def _message_error_received(self,
                                 _stanza: nbxmpp.Message,
                                 properties: MessageProperties
                                 ) -> None:
-        jid = properties.jid
-        if not properties.is_muc_pm:
-            jid = jid.new_as_bare()
 
-        self._log.info(properties.error)
+        remote_jid = properties.remote_jid
+        message_id = properties.id
 
-        app.storage.archive.set_message_error(
-            app.get_jid_from_account(self._account),
-            jid,
-            properties.id,
-            properties.error)
+        error_data = DbInsertErrorsRowData(
+            account_jid=self._account,
+            remote_jid=remote_jid,
+            message_id=message_id,
+            by=properties.error.by,
+            e_type=properties.error.type,
+            text=properties.error.get_text() or None,
+            condition=properties.error.condition,
+            condition_text=properties.error.condition_data,
+        )
+        app.storage.archive.insert_row(error_data)
 
         app.ged.raise_event(
             MessageError(account=self._account,
-                         jid=jid,
-                         room_jid=jid,
-                         message_id=properties.id,
+                         jid=remote_jid,
+                         message_id=message_id,
                          error=properties.error))
 
     def _check_for_mam_compliance(self, room_jid: str, stanza_id: str) -> None:


=====================================
gajim/common/storage/archive2/statements.py
=====================================
@@ -214,6 +214,7 @@
         errors.e_type AS t_errors_e_type,
         errors.text AS t_errors_text,
         errors.condition AS t_errors_condition,
+        errors.condition_text AS t_errors_condition_text,
         oob.url AS t_oob_url,
         oob.description AS t_oob_description,
         reply.fallback_end AS t_reply_fallback_end,


=====================================
gajim/common/storage/archive2/structs.py
=====================================
@@ -70,11 +70,11 @@ class DbMarkersRowData:
 
 @dataclasses.dataclass
 class DbErrorsRowData:
-    by: str | None
     e_type: str
-    text: str | None
     condition: str
-    condition_text: str | None
+    by: str | None = None
+    text: str | None = None
+    condition_text: str | None = None
 
 
 @dataclasses.dataclass



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/eedcc108409f80794978324e382edc3f67423649

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/eedcc108409f80794978324e382edc3f67423649
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to