Replaced the post button for post in wall in people buffers

This commit is contained in:
Manuel Cortez 2019-09-15 12:42:01 -05:00
parent 33ab63c1bc
commit 61583447b6
4 changed files with 27 additions and 7 deletions

View File

@ -21,6 +21,7 @@
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, 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. Later change will also be introduced when posting comments, too. * Socializer is now more tolerant to internet issues. When attempting to create a wall post, 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. Later change will also be introduced when posting comments, too.
* Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly. * Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly.
* automatic update checks will be disabled if using socializer from the source code. * automatic update checks will be disabled if using socializer from the source code.
* it is possible to post in an user's wall by using the post button located next to the user, in people buffers. This applies only to online users and list of friends.
## changes in Versions 0.21 and 0.22 (14.07.2019) ## changes in Versions 0.21 and 0.22 (14.07.2019)

View File

@ -1283,6 +1283,21 @@ class chatBuffer(baseBuffer):
class peopleBuffer(feedBuffer): class peopleBuffer(feedBuffer):
def post(self, *args, **kwargs):
user = self.get_post()
if "can_post" not in user: # retrieve data if not present in the object.
user = self.session.vk.client.users.get(user_ids=user["id"], fields="can_post")[0]
if user.get("can_post") == True:
user_str = self.session.get_user(user["id"], key="user1")
title = _("Post to {user1_nom}'s wall").format(**user_str)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=user["id"])
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.peopleTab(parent) self.tab = home.peopleTab(parent)
self.connect_events() self.connect_events()
@ -1305,6 +1320,10 @@ class peopleBuffer(feedBuffer):
post = self.get_post() post = self.get_post()
if post == None: if post == None:
return return
if post.get("can_post") == True:
self.tab.post.Enable(True)
else:
self.tab.post.Enable(False)
if ("last_seen" in post) == False: return if ("last_seen" in post) == False: return
original_date = arrow.get(post["last_seen"]["time"]) original_date = arrow.get(post["last_seen"]["time"])
now = arrow.now() now = arrow.now()

View File

@ -127,12 +127,12 @@ class Controller(object):
pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"])) pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"]))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen")) pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen")) pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs")) pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))
@ -460,7 +460,7 @@ class Controller(object):
break break
if user == None: if user == None:
log.exception("Getting user manually...") log.exception("Getting user manually...")
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen")[0] user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen, can_post")[0]
wx.CallAfter(online_buffer.add_person, user) wx.CallAfter(online_buffer.add_person, user)
def user_offline(self, event): def user_offline(self, event):

View File

@ -265,7 +265,7 @@ class peopleTab(homeTab):
def create_post_buttons(self): def create_post_buttons(self):
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions")) self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post")) self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post on user's wall"))
self.new_chat = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Send message")) self.new_chat = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Send message"))
self.postBox.Add(self.post, 0, wx.ALL, 5) self.postBox.Add(self.post, 0, wx.ALL, 5)
self.postBox.Add(self.new_chat, 0, wx.ALL, 5) self.postBox.Add(self.new_chat, 0, wx.ALL, 5)