From 60d283f931effaed14715761b1877ba994c50f14 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 28 Aug 2019 08:53:37 -0500 Subject: [PATCH] Added some comments to the new post function --- src/sessionmanager/session.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index 2d7c5e2..08ee742 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -312,12 +312,16 @@ class vkSession(object): """ Generic function to be called whenever user wants to post something to VK. This function should be capable of uploading all attachments before posting, and send a special event in case the post has failed, So the program can recreate the post and show it back to the user.""" + # ToDo: this function will occasionally be called with attachments already set to post_arguments, example if the user could upload the files but was unable to send the post due to a connection problem. + # We should see what can be done (reuploading everything vs using the already added attachments). attachments = "" + # Firstly, let's try to upload the attachments here. If peer_id exists in post_arguments, + # It means we are talking about private messages, whose attachment procedures have their own methods. if len(attachments_list) > 0: try: attachments = self.upload_attachments(attachments_list, post_arguments.get("peer_id")) except Exception as error: - log.exception("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. pub.sendMessage("postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments) # VK generally defines all kind of messages under "text", "message" or "body" so let's try with all of those