Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Smith <mrdoctorwho@helldev.net>2018-12-30 18:31:07 +0300
committerJohn Smith <mrdoctorwho@helldev.net>2018-12-30 18:31:07 +0300
commit715f5bd63c937252f60e3b71c99467c4f6343e94 (patch)
treee5e8a95478719bfc7df942a118be5cef6a4bdfe5
parent0a97a19a4dcc78c10c87c30baa77d7a24224db9e (diff)
try to fetch original url for documents if possible (for shorter links)
-rw-r--r--extensions/attachments.py6
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)