Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0231.py @ 3333:ac9342f359e9
plugin XEP-0329: download thumbnails:
- thumbnails are now downloaded directly when BoB is used, `filename` is then filled
- `utils.asDeferred` is now used for Jingle methods, so `async` coroutines can be used
- (XEP-0231): fixed `dumpData`
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 13 Aug 2020 23:46:18 +0200 |
parents | 4230aaeab9a7 |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3332:1512cbd6c4ac | 3333:ac9342f359e9 |
---|---|
15 # GNU Affero General Public License for more details. | 15 # GNU Affero General Public License for more details. |
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 import base64 |
21 from sat.core.constants import Const as C | 21 import time |
22 from sat.core import exceptions | 22 from pathlib import Path |
23 from sat.core.log import getLogger | 23 from functools import partial |
24 | |
25 log = getLogger(__name__) | |
26 from sat.tools import xml_tools | |
27 from wokkel import disco, iwokkel | |
28 from zope.interface import implementer | 24 from zope.interface import implementer |
29 from twisted.python import failure | 25 from twisted.python import failure |
30 from twisted.words.protocols.jabber import xmlstream | 26 from twisted.words.protocols.jabber import xmlstream |
31 from twisted.words.protocols.jabber import jid | 27 from twisted.words.protocols.jabber import jid |
32 from twisted.words.protocols.jabber import error as jabber_error | 28 from twisted.words.protocols.jabber import error as jabber_error |
33 from twisted.internet import defer | 29 from twisted.internet import defer |
34 from functools import partial | 30 from wokkel import disco, iwokkel |
35 import base64 | 31 from sat.tools import xml_tools |
36 import time | 32 from sat.core.i18n import _ |
33 from sat.core.constants import Const as C | |
34 from sat.core import exceptions | |
35 from sat.core.log import getLogger | |
36 | |
37 log = getLogger(__name__) | |
37 | 38 |
38 | 39 |
39 PLUGIN_INFO = { | 40 PLUGIN_INFO = { |
40 C.PI_NAME: "Bits of Binary", | 41 C.PI_NAME: "Bits of Binary", |
41 C.PI_IMPORT_NAME: "XEP-0231", | 42 C.PI_IMPORT_NAME: "XEP-0231", |
88 | 89 |
89 with cache.cacheData( | 90 with cache.cacheData( |
90 PLUGIN_INFO[C.PI_IMPORT_NAME], cid, data_elt.getAttribute("type"), max_age | 91 PLUGIN_INFO[C.PI_IMPORT_NAME], cid, data_elt.getAttribute("type"), max_age |
91 ) as f: | 92 ) as f: |
92 | 93 |
93 file_path = f.name | 94 file_path = Path(f.name) |
94 f.write(base64.b64decode(str(data_elt))) | 95 f.write(base64.b64decode(str(data_elt))) |
95 | 96 |
96 return file_path | 97 return file_path |
97 | 98 |
98 def getHandler(self, client): | 99 def getHandler(self, client): |