Fixed error that was making some links to redirect to 404 errors in chat messages, posts and comments

This commit is contained in:
2019-11-20 16:18:16 -06:00
parent bb92a8a8d4
commit 55193a958d
4 changed files with 27 additions and 12 deletions

View File

@@ -567,9 +567,10 @@ class Controller(object):
return
# If the chat already exists, let's create a dictionary wich will contains data of the received message.
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=utils.clean_text(obj.text), attachments=obj.attachments)
# if attachments is true, let's request for the full message with attachments formatted in a better way.
# if attachments is true or body contains at least an URL, let's request for the full message with attachments formatted in a better way.
# ToDo: code improvements. We shouldn't need to request the same message again just for these attachments.
if len(message["attachments"]) != 0:
if len(message["attachments"]) != 0 or len(utils.find_urls_in_text(message["body"])) != 0:
print(message["body"])
message_ids = message["id"]
results = self.session.vk.client.messages.getById(message_ids=message_ids)
message = results["items"][0]