Daniel Brötzmann pushed to branch storage at gajim / gajim


Commits:
623b8bd5 by wurstsalat at 2024-03-18T20:56:58+01:00
imprv: Don't allow certain actions on pending messages

This concerns message corrections, message deletion, message retraction, and 
message quoting

- - - - -


3 changed files:

- gajim/common/storage/archive/storage.py
- gajim/gtk/conversation/rows/message.py
- gajim/gtk/menus.py


Changes:

=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -420,6 +420,7 @@ def get_last_correctable_message(
                 Message.fk_account_pk == fk_account_pk,
                 Message.id == message_id,
                 Message.timestamp > min_time,
+                Message.state == MessageState.ACKNOWLEDGED
             )
             .order_by(sa.desc(Message.timestamp), sa.desc(Message.pk))
             .limit(1)


=====================================
gajim/gtk/conversation/rows/message.py
=====================================
@@ -245,7 +245,8 @@ def _on_more_menu_button_clicked(self, button: Gtk.Button) 
-> None:
             self.message_id,
             self.stanza_id,
             self.orig_log_line_id,
-            self.log_line_id)
+            self.log_line_id,
+            self.state)
 
         popover = GajimPopover(menu, relative_to=button)
         popover.popup()


=====================================
gajim/gtk/menus.py
=====================================
@@ -37,6 +37,7 @@
 from gajim.common.modules.contacts import GroupchatContact
 from gajim.common.modules.contacts import GroupchatParticipant
 from gajim.common.preview import Preview
+from gajim.common.storage.archive.const import MessageState
 from gajim.common.structs import URI
 from gajim.common.util.text import escape_iri_path_segment
 
@@ -693,6 +694,7 @@ def get_chat_row_menu(contact: types.ChatContactT,
                       stanza_id: str | None,
                       pk: int | None,
                       corrected_pk: int | None,
+                      state: MessageState,
                       ) -> GajimMenu:
 
     menu_items: MenuItemListT = []
@@ -716,12 +718,13 @@ def get_chat_row_menu(contact: types.ChatContactT,
 
         show_quote = True
         if isinstance(contact, GroupchatContact):
-            if contact.is_joined:
+            if contact.is_joined and state == MessageState.ACKNOWLEDGED:
                 self_contact = contact.get_self()
                 assert self_contact is not None
                 show_quote = not self_contact.role.is_visitor
             else:
                 show_quote = False
+
         if show_quote:
             menu_items.append((
                 p_('Message row action', 'Quote…'), 'win.quote', text))
@@ -751,7 +754,9 @@ def get_chat_row_menu(contact: types.ChatContactT,
 
         if disco_info.has_message_moderation and is_allowed:
             show_retract = True
-    if show_retract and stanza_id is not None:
+
+    if (show_retract and stanza_id is not None
+            and state == MessageState.ACKNOWLEDGED):
         param = RetractMessageParam(
             account=contact.account,
             jid=contact.jid,
@@ -761,7 +766,7 @@ def get_chat_row_menu(contact: types.ChatContactT,
             'win.retract-message',
             param))
 
-    if pk is not None:
+    if pk is not None and state == MessageState.ACKNOWLEDGED:
         param = DeleteMessageParam(
             account=contact.account,
             jid=contact.jid,



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/623b8bd527d21f5ee37175b7366c88bcd0107574
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