Added error reports to failed posts in VK (pubsub). Added an extra param called from_post which specifies which buffer will get updated if the post is created successfully

This commit is contained in:
2019-08-27 16:59:57 -05:00
parent a7173adc22
commit f41dd51dc7
3 changed files with 26 additions and 19 deletions

View File

@@ -130,7 +130,7 @@ class baseBuffer(object):
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", attachments_list=attachments, post_arguments=post_arguments)
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def connect_events(self):
""" Bind all events to this buffer"""
@@ -417,7 +417,7 @@ class feedBuffer(baseBuffer):
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", attachments_list=attachments, post_arguments=post_arguments)
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
@@ -478,7 +478,7 @@ class communityBuffer(feedBuffer):
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", attachments_list=attachments, post_arguments=post_arguments)
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
class topicBuffer(feedBuffer):
@@ -531,7 +531,7 @@ class topicBuffer(feedBuffer):
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="addTopic", attachments_list=attachments, post_arguments=post_arguments)
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="addTopic", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
class documentBuffer(feedBuffer):
can_get_items = False

View File

@@ -332,15 +332,11 @@ class Controller(object):
pub.unsubscribe(self.notify, "notify")
pub.subscribe(self.create_timeline, "create-timeline")
def in_post(self, buffer):
""" This event is triggered whenever an user requires an update in their buffers. For example after sending a post successfully.
The function updates the main newsfeed buffer, and the buffer from where the post was sent.
@buffer str: name of the buffer where the post has been generated.
"""
buffer = self.search(buffer)
buffer.get_items()
buffer = self.search("home_timeline")
buffer.get_items()
def in_post(self, from_buffer=None):
if from_buffer != None:
log.debug("Post received in buffer %s, updating... " % (from_buffer,))
buffer = self.search(from_buffer)
buffer.get_items()
def download(self, url, filename):
""" Download a file to te current user's computer.