diff options
author | John Smith <mrdoctorwho@helldev.net> | 2018-12-30 18:31:07 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@helldev.net> | 2018-12-30 18:31:07 +0300 |
commit | 715f5bd63c937252f60e3b71c99467c4f6343e94 (patch) | |
tree | e5e8a95478719bfc7df942a118be5cef6a4bdfe5 | |
parent | 0a97a19a4dcc78c10c87c30baa77d7a24224db9e (diff) |
try to fetch original url for documents if possible (for shorter links)
-rw-r--r-- | extensions/attachments.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/extensions/attachments.py b/extensions/attachments.py index 009aac6..164041a 100644 --- a/extensions/attachments.py +++ b/extensions/attachments.py @@ -125,6 +125,12 @@ def attachments_msg03(msg, destination, source): match = ATTACHMENT_REGEX.match(body.encode("utf-8")) if match: link = match.group("url") + if link: + try: + link = urllib.urlopen(link).url + except Exception: + crashLog("attachments_msg03") + logger.error("unable to fetch real url for link %s and (jid: %s)", (link, user.source)) url = msg.setTag("x", namespace=xmpp.NS_OOB) url.setTagData("url", link) msg.setBody(link) |