TWBlue should not allow users to retweet or quote any protected account. Closes #454

This commit is contained in:
Manuel Cortez 2022-01-25 12:01:03 -06:00
parent 6e0a94355f
commit ac0e7380b0
No known key found for this signature in database
GPG Key ID: 262CC30FA01B5CBF
3 changed files with 19 additions and 0 deletions

View File

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

View File

@ -391,6 +391,12 @@ class BaseBuffer(base.Buffer):
tweet = self.session.db[self.name][self.buffer.list.get_selected()] tweet = self.session.db[self.name][self.buffer.list.get_selected()]
return tweet 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 @_tweets_exist
def reply(self, *args, **kwargs): def reply(self, *args, **kwargs):
tweet = self.get_right_tweet() tweet = self.get_right_tweet()
@ -442,6 +448,8 @@ class BaseBuffer(base.Buffer):
@_tweets_exist @_tweets_exist
def share_item(self, *args, **kwargs): 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() tweet = self.get_right_tweet()
id = tweet.id id = tweet.id
if self.session.settings["general"]["retweet_mode"] == "ask": if self.session.settings["general"]["retweet_mode"] == "ask":
@ -483,6 +491,9 @@ class BaseBuffer(base.Buffer):
self.session.sound.play("geo.ogg") self.session.sound.play("geo.ogg")
if self.session.settings['sound']['indicate_img'] and utils.is_media(tweet): if self.session.settings['sound']['indicate_img'] and utils.is_media(tweet):
self.session.sound.play("image.ogg") 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): def audio(self, url='', *args, **kwargs):
if sound.URLPlayer.player.is_playing(): 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_blocked_user, "blocked-user")
pub.subscribe(self.manage_unblocked_user, "unblocked-user") pub.subscribe(self.manage_unblocked_user, "unblocked-user")
pub.subscribe(self.create_buffer, "createBuffer") pub.subscribe(self.create_buffer, "createBuffer")
pub.subscribe(self.toggle_share_settings, "toggleShare")
if system == "Windows": if system == "Windows":
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed") pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide) 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"]: if sound_to_play != None and buff not in buffer.session.settings["other_buffers"]["muted_buffers"]:
self.notify(buffer.session, sound_to_play) self.notify(buffer.session, sound_to_play)
def toggle_share_settings(self, shareable=True):
self.view.retweet.Enable(shareable)
def check_streams(self): def check_streams(self):
if self.started == False: if self.started == False:
return return