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

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

View File

@ -4,6 +4,16 @@
### New additions ### New additions
### bugfixes
* Fixed an error that was making socializer unable to render correctly certain Links containing uppercase letters (such as yandex.disk shared links). Before, those links were giving 404 errors when pressed, now they should work normally. This error was present in wall posts, comments, topics and chat messages.
### Changes
## Changes in Version 0.23 (11.11.2019)
### New additions
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later. * Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later.
* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in. * Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in.
* when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs. * when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs.

View File

@ -17,6 +17,8 @@ backports.functools_lru_cache
yandex.translate yandex.translate
mutagen mutagen
mock mock
# cx_freeze for building the executable files.
cx_freeze
# forked repositories previously found at http://q-continuum.net # forked repositories previously found at http://q-continuum.net
git+https://code.manuelcortez.net/manuelcortez/libloader git+https://code.manuelcortez.net/manuelcortez/libloader
git+https://code.manuelcortez.net/manuelcortez/platform_utils git+https://code.manuelcortez.net/manuelcortez/platform_utils

View File

@ -567,9 +567,10 @@ class Controller(object):
return return
# If the chat already exists, let's create a dictionary wich will contains data of the received message. # 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) 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. # 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"] message_ids = message["id"]
results = self.session.vk.client.messages.getById(message_ids=message_ids) results = self.session.vk.client.messages.getById(message_ids=message_ids)
message = results["items"][0] message = results["items"][0]

View File

@ -147,6 +147,7 @@ class vkSession(object):
self.logged = True self.logged = True
self.get_my_data() self.get_my_data()
except VkApiError as error: except VkApiError as error:
print(error)
if error.code == 5: # this means invalid access token. if error.code == 5: # this means invalid access token.
self.settings["vk"]["user"] = "" self.settings["vk"]["user"] = ""
self.settings["vk"]["password"] = "" self.settings["vk"]["password"] = ""
@ -330,17 +331,18 @@ class vkSession(object):
log.error("Error calling method %s.%s with arguments: %r. Failed during loading attachments. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error))) log.error("Error calling method %s.%s with arguments: %r. Failed during loading attachments. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error)))
# Report a failed function here too with same arguments so the client should be able to recreate it again. # Report a failed function here too with same arguments so the client should be able to recreate it again.
wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments) wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
### ToDo: Let's avoid this piece of code cause it seems VK changes everything to lowercase letters.
# VK generally defines all kind of messages under "text", "message" or "body" so let's try with all of those # VK generally defines all kind of messages under "text", "message" or "body" so let's try with all of those
possible_message_keys = ["text", "message", "body"] # possible_message_keys = ["text", "message", "body"]
for i in possible_message_keys: # for i in possible_message_keys:
if post_arguments.get(i): # if post_arguments.get(i):
urls = utils.find_urls_in_text(post_arguments[i]) # urls = utils.find_urls_in_text(post_arguments[i])
if len(urls) != 0: # if len(urls) != 0:
if len(attachments) == 0: # if len(attachments) == 0:
attachments = urls[0] # attachments = urls[0]
else: # else:
attachments += urls[0] # attachments += urls[0]
post_arguments[i] = post_arguments[i].replace(urls[0], "") # post_arguments[i] = post_arguments[i].replace(urls[0], "")
# After modifying everything, let's update the post arguments if needed. # After modifying everything, let's update the post arguments if needed.
if len(attachments) > 0: if len(attachments) > 0:
if parent_endpoint == "messages": if parent_endpoint == "messages":