# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1667084818 -7200
# Node ID d105ead599b60ff063891c7bd76e45d9ac472bc1
# Parent  2d9d0b77e82b20be24d978c89ccba56bb77268a0
plugin pubsub signature: fix attachment setting + default signer:

- attachment setting was crashing when `item_elt` was not specified due to argument typo
- if `signer` is set to None in attachment data, client's bare jid will be used to sign
  the item

rel 381

diff -r 2d9d0b77e82b -r d105ead599b6 sat/plugins/plugin_sec_pubsub_signing.py
--- a/sat/plugins/plugin_sec_pubsub_signing.py	Sun Oct 30 01:06:55 2022 +0200
+++ b/sat/plugins/plugin_sec_pubsub_signing.py	Sun Oct 30 01:06:58 2022 +0200
@@ -255,7 +255,7 @@
                 node = attachments_data["node"]
                 item_id = attachments_data["id"]
                 items, __ = await self._p.getItems(
-                    client, service, node, items_ids=[item_id]
+                    client, service, node, item_ids=[item_id]
                 )
                 if not items != 1:
                     raise exceptions.NotFound(
@@ -263,7 +263,7 @@
                     )
                 item_elt = items[0]
 
-            signer = signature_data["signer"]
+            signer = signature_data.get("signer") or client.jid.userhost()
             timestamp = time.time()
             timestamp_xmpp = utils.xmpp_date(timestamp)
             to_sign = self.get_data_to_sign(item_elt, service, timestamp, signer)