Merge pull request #455 from manuelcortez/handle_protected_account_interactions

Protected account retweet restrictions
This commit is contained in:
Manuel Cortez 2022-01-25 12:04:21 -06:00 committed by GitHub
commit 950ece43d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -125,6 +125,9 @@ class Buffer(object):
def share_item(self):
pass
def can_share(self):
pass
def destroy_status(self):
pass

View File

@ -391,6 +391,12 @@ class BaseBuffer(base.Buffer):
tweet = self.session.db[self.name][self.buffer.list.get_selected()]
return tweet
def can_share(self):
tweet = self.get_right_tweet()
user = self.session.get_user(tweet.user)
is_protected = user.protected
return is_protected==False
@_tweets_exist
def reply(self, *args, **kwargs):
tweet = self.get_right_tweet()
@ -442,6 +448,8 @@ class BaseBuffer(base.Buffer):
@_tweets_exist
def share_item(self, *args, **kwargs):
if self.can_share() == False:
return output.speak(_("This action is not supported on protected accounts."))
tweet = self.get_right_tweet()
id = tweet.id
if self.session.settings["general"]["retweet_mode"] == "ask":
@ -483,6 +491,9 @@ class BaseBuffer(base.Buffer):
self.session.sound.play("geo.ogg")
if self.session.settings['sound']['indicate_img'] and utils.is_media(tweet):
self.session.sound.play("image.ogg")
can_share = self.can_share()
pub.sendMessage("toggleShare", shareable=can_share)
self.buffer.retweet.Enable(can_share)
def audio(self, url='', *args, **kwargs):
if sound.URLPlayer.player.is_playing():

View File

@ -134,6 +134,7 @@ class Controller(object):
pub.subscribe(self.manage_blocked_user, "blocked-user")
pub.subscribe(self.manage_unblocked_user, "unblocked-user")
pub.subscribe(self.create_buffer, "createBuffer")
pub.subscribe(self.toggle_share_settings, "toggleShare")
if system == "Windows":
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide)
@ -1657,6 +1658,10 @@ class Controller(object):
if sound_to_play != None and buff not in buffer.session.settings["other_buffers"]["muted_buffers"]:
self.notify(buffer.session, sound_to_play)
def toggle_share_settings(self, shareable=True):
self.view.retweet.Enable(shareable)
def check_streams(self):
if self.started == False:
return