mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Avoid timeline creation of unauthorized accounts. Fixes #125
This commit is contained in:
parent
66774174ae
commit
cced182063
@ -9,6 +9,7 @@
|
||||
* The spellchecker module should select the right language when is set to "user default". ([#117](https://github.com/manuelcortez/TWBlue/issues/117))
|
||||
* Image description will be displayed in retweets too. ([#119](https://github.com/manuelcortez/TWBlue/issues/119))
|
||||
* When reading a long tweet, you shouldn't read strange entities anymore. ([#118](https://github.com/manuelcortez/twblue/issues/118))
|
||||
* TWBlue will not try to load timelines if the user is blocking you. ([#125](https://github.com/manuelcortez/twblue/issues/125))
|
||||
|
||||
## Changes in version 0.88 and 0.89
|
||||
|
||||
|
@ -25,7 +25,7 @@ from sessionmanager import session as session_
|
||||
from pubsub import pub
|
||||
import sound
|
||||
import output
|
||||
from twython import TwythonError
|
||||
from twython import TwythonError, TwythonAuthError
|
||||
from mysc.thread_utils import call_threaded
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc import restart
|
||||
@ -807,11 +807,16 @@ class Controller(object):
|
||||
commonMessageDialogs.timeline_exist()
|
||||
return
|
||||
tl = buffersController.baseBufferController(self.view.nb, "get_user_timeline", "%s-timeline" % (usr["id_str"],), buff.session, buff.session.db["user_name"], bufferType=None, user_id=usr["id_str"], tweet_mode="extended")
|
||||
try:
|
||||
tl.start_stream()
|
||||
except TwythonAuthError:
|
||||
commonMessageDialogs.unauthorized()
|
||||
return
|
||||
pos=self.view.search("timelines", buff.session.db["user_name"])
|
||||
self.insert_buffer(tl, pos+1)
|
||||
self.view.insert_buffer(tl.buffer, name=_(u"Timeline for {}").format(dlg.get_user()), pos=pos)
|
||||
buff.session.settings["other_buffers"]["timelines"].append(usr["id_str"])
|
||||
tl.start_stream()
|
||||
pub.sendMessage("buffer-title-changed", buffer=tl)
|
||||
pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session)
|
||||
buff.session.sound.play("create_timeline.ogg")
|
||||
elif tl_type == "favourites":
|
||||
@ -822,13 +827,18 @@ class Controller(object):
|
||||
commonMessageDialogs.timeline_exist()
|
||||
return
|
||||
tl = buffersController.baseBufferController(self.view.nb, "get_favorites", "%s-favorite" % (usr["id_str"],), buff.session, buff.session.db["user_name"], bufferType=None, user_id=usr["id_str"], tweet_mode="extended")
|
||||
try:
|
||||
tl.start_stream()
|
||||
except TwythonAuthError:
|
||||
commonMessageDialogs.unauthorized()
|
||||
return
|
||||
pos=self.view.search("favs_timelines", buff.session.db["user_name"])
|
||||
self.insert_buffer(tl, pos+1)
|
||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Likes for {}").format(dlg.get_user()), pos=pos)
|
||||
tl.start_stream()
|
||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||
tl.timer.start()
|
||||
buff.session.settings["other_buffers"]["favourites_timelines"].append(usr["id_str"])
|
||||
pub.sendMessage("buffer-title-changed", buffer=i)
|
||||
buff.session.sound.play("create_timeline.ogg")
|
||||
elif tl_type == "followers":
|
||||
if usr["followers_count"] == 0:
|
||||
@ -838,14 +848,19 @@ class Controller(object):
|
||||
commonMessageDialogs.timeline_exist()
|
||||
return
|
||||
tl = buffersController.peopleBufferController(self.view.nb, "get_followers_list", "%s-followers" % (usr["id_str"],), buff.session, buff.session.db["user_name"], user_id=usr["id_str"])
|
||||
try:
|
||||
tl.start_stream()
|
||||
except TwythonAuthError:
|
||||
commonMessageDialogs.unauthorized()
|
||||
return
|
||||
pos=self.view.search("followers_timelines", buff.session.db["user_name"])
|
||||
self.insert_buffer(tl, pos+1)
|
||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Followers for {}").format(dlg.get_user()), pos=pos)
|
||||
tl.start_stream()
|
||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||
tl.timer.start()
|
||||
buff.session.settings["other_buffers"]["followers_timelines"].append(usr["id_str"])
|
||||
buff.session.sound.play("create_timeline.ogg")
|
||||
pub.sendMessage("buffer-title-changed", buffer=i)
|
||||
elif tl_type == "friends":
|
||||
if usr["friends_count"] == 0:
|
||||
commonMessageDialogs.no_friends()
|
||||
@ -854,14 +869,19 @@ class Controller(object):
|
||||
commonMessageDialogs.timeline_exist()
|
||||
return
|
||||
tl = buffersController.peopleBufferController(self.view.nb, "get_friends_list", "%s-friends" % (usr["id_str"],), buff.session, buff.session.db["user_name"], user_id=usr["id_str"])
|
||||
try:
|
||||
tl.start_stream()
|
||||
except TwythonAuthError:
|
||||
commonMessageDialogs.unauthorized()
|
||||
return
|
||||
pos=self.view.search("friends_timelines", buff.session.db["user_name"])
|
||||
self.insert_buffer(tl, pos+1)
|
||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Friends for {}").format(dlg.get_user()), pos=pos)
|
||||
tl.start_stream()
|
||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||
tl.timer.start()
|
||||
buff.session.settings["other_buffers"]["friends_timelines"].append(usr["id_str"])
|
||||
buff.session.sound.play("create_timeline.ogg")
|
||||
pub.sendMessage("buffer-title-changed", buffer=i)
|
||||
else:
|
||||
commonMessageDialogs.user_not_exist()
|
||||
buff.session.settings.write()
|
||||
@ -1311,7 +1331,24 @@ class Controller(object):
|
||||
log.debug("starting buffers... Session %s" % (session.session_id,))
|
||||
for i in self.buffers:
|
||||
if i.session == session and i.needs_init == True:
|
||||
i.start_stream()
|
||||
if hasattr(i, "finished_timeline") and i.finished_timeline == False:
|
||||
change_title = True
|
||||
else:
|
||||
change_title = False
|
||||
try:
|
||||
i.start_stream()
|
||||
except TwythonAuthError:
|
||||
buff = self.view.search(i.name, i.account)
|
||||
i.remove_buffer(force=True)
|
||||
commonMessageDialogs.blocked_timeline()
|
||||
if self.get_current_buffer() == i:
|
||||
self.right()
|
||||
self.view.delete_buffer(buff)
|
||||
self.buffers.remove(i)
|
||||
del i
|
||||
continue
|
||||
if change_title:
|
||||
pub.sendMessage("buffer-title-changed", buffer=i)
|
||||
log.debug("Starting the streaming endpoint")
|
||||
session.start_streaming()
|
||||
|
||||
@ -1490,9 +1527,19 @@ class Controller(object):
|
||||
getattr(self, action)()
|
||||
|
||||
def restart_streams_(self, session):
|
||||
for i in self.buffers:
|
||||
for i in self.buffers[:]:
|
||||
if i.session != None and i.session.session_id == session:
|
||||
i.start_stream()
|
||||
try:
|
||||
i.start_stream()
|
||||
except TwythonAuthError:
|
||||
buff = self.view.search(i.name, i.account)
|
||||
i.remove_buffer(force=True)
|
||||
commonMessageDialogs.blocked_timeline()
|
||||
if self.get_current_buffer() == i:
|
||||
self.right()
|
||||
self.view.delete_buffer(buff)
|
||||
self.buffers.remove(i)
|
||||
del i
|
||||
|
||||
def update_buffer(self, *args, **kwargs):
|
||||
bf = self.get_current_buffer()
|
||||
|
@ -71,3 +71,9 @@ def view_geodata(geotext):
|
||||
|
||||
def changed_keymap():
|
||||
return wx.MessageDialog(None, _(u"TWBlue has detected that you're running windows 10 and has changed the default keymap to the Windows 10 keymap. It means that some keyboard shorcuts could be different. Please check the keystroke editor by pressing Alt+Win+K to see all available keystrokes for this keymap."), _(u"Information"), wx.OK).ShowModal()
|
||||
|
||||
def unauthorized():
|
||||
return wx.MessageDialog(None, _(u"You have been blocked from viewing this content"), _(u"Error"), wx.OK).ShowModal()
|
||||
|
||||
def blocked_timeline():
|
||||
return wx.MessageDialog(None, _(u"You have been blocked from viewing someone's content. In order to avoid conflicts with the full session, TWBlue will remove the affected timeline."), _(u"Error"), wx.OK).ShowModal()
|
Loading…
Reference in New Issue
Block a user