comparison sat/plugins/plugin_misc_attach.py @ 3859:3ef988734869

core: fix calls to `domish.Element.elements`: domish.Element.elements should be called with namespace and element name as 2 arguments, but it has been confused in several places with the call to `domish.Element.addElement` which is often done with a `(namespace, name)` tuple. Unfortunately calling with a tuple is accepted and doesn't raise any error in `elements`, but this result in a wrong element returned. This patch fixes the erroneous calls.
author Goffi <goffi@goffi.org>
date Wed, 20 Jul 2022 17:12:29 +0200
parents be6d91572633
children 0ff265725489
comparison
equal deleted inserted replaced
3858:6e785662dd7d 3859:3ef988734869
246 return True 246 return True
247 247
248 async def defaultAttach(self, client, data): 248 async def defaultAttach(self, client, data):
249 await self.uploadFiles(client, data) 249 await self.uploadFiles(client, data)
250 # TODO: handle xhtml-im 250 # TODO: handle xhtml-im
251 body_elt = next(data["xml"].elements((C.NS_CLIENT, "body"))) 251 body_elt = next(data["xml"].elements(C.NS_CLIENT, "body"))
252 attachments = data["extra"][C.MESS_KEY_ATTACHMENTS] 252 attachments = data["extra"][C.MESS_KEY_ATTACHMENTS]
253 if attachments: 253 if attachments:
254 body_links = '\n'.join(a['url'] for a in attachments) 254 body_links = '\n'.join(a['url'] for a in attachments)
255 if str(body_elt).strip(): 255 if str(body_elt).strip():
256 # if there is already a body, we add a line feed before the first link 256 # if there is already a body, we add a line feed before the first link