Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0231.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
183 if metadata is None: | 183 if metadata is None: |
184 error_elt = jabber_error.StanzaError("item-not-found").toResponse(iq_elt) | 184 error_elt = jabber_error.StanzaError("item-not-found").toResponse(iq_elt) |
185 client.send(error_elt) | 185 client.send(error_elt) |
186 return | 186 return |
187 | 187 |
188 with open(metadata["path"], 'rb') as f: | 188 with open(metadata["path"], "rb") as f: |
189 data = f.read() | 189 data = f.read() |
190 | 190 |
191 result_elt = xmlstream.toResponse(iq_elt, "result") | 191 result_elt = xmlstream.toResponse(iq_elt, "result") |
192 data_elt = result_elt.addElement( | 192 data_elt = result_elt.addElement( |
193 (NS_BOB, "data"), content=base64.b64encode(data).decode()) | 193 (NS_BOB, "data"), content=base64.b64encode(data).decode() |
194 ) | |
194 data_elt["cid"] = cid | 195 data_elt["cid"] = cid |
195 data_elt["type"] = metadata["mime_type"] | 196 data_elt["type"] = metadata["mime_type"] |
196 data_elt["max-age"] = str(int(max(0, metadata["eol"] - time.time()))) | 197 data_elt["max-age"] = str(int(max(0, metadata["eol"] - time.time()))) |
197 client.send(result_elt) | 198 client.send(result_elt) |
198 | 199 |
238 self.host = plugin_parent.host | 239 self.host = plugin_parent.host |
239 | 240 |
240 def connectionInitialized(self): | 241 def connectionInitialized(self): |
241 if self.parent.is_component: | 242 if self.parent.is_component: |
242 self.xmlstream.addObserver( | 243 self.xmlstream.addObserver( |
243 IQ_BOB_REQUEST, self.plugin_parent.on_component_request, client=self.parent | 244 IQ_BOB_REQUEST, |
245 self.plugin_parent.on_component_request, | |
246 client=self.parent, | |
244 ) | 247 ) |
245 | 248 |
246 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): | 249 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
247 return [disco.DiscoFeature(NS_BOB)] | 250 return [disco.DiscoFeature(NS_BOB)] |
248 | 251 |