Skip to content

Commit

Permalink
handle mentions more easily, and correct the mentions vs notification…
Browse files Browse the repository at this point in the history
…s typo -- but in the process i upgraded mastodon.py and it broke some basic stuff (like message IDs, now numeric)
  • Loading branch information
enkiv2 committed Jul 14, 2022
1 parent fd152c9 commit b420ad9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fern
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ def getTimeline(which=None, **kw_args):
tl=[]
tl2=[]
if(which=="notifications"):
notes=mastodon.notifications()
for note in notes:
if note["type"]=="mention": tl2.append(note["status"])
tl2=[x["status"] for x in mastodon.notifications(mentions_only=True)]
else: tl2=mastodon.timeline(timeline=which, **kw_args)
tl.extend(ensureCached(tl2, verbose=True))
saveBase()
Expand Down Expand Up @@ -568,8 +566,10 @@ def importHistory(src="all", verbose=False):
page=mastodon.account_statuses(mastodon.account_verify_credentials()["id"])
elif src in ["favorites", "favourites"]:
page=mastodon.favourites()
elif src=="notifications":
elif src==["notifications"]: # xxx: notifications are handled differently
page=mastodon.notifications()
elif src==["mentions"]:
page=mastodon.notifications(mentions_only=True)
else:
statusMsg("Unknown history source: "+src)
return []
Expand Down Expand Up @@ -641,19 +641,23 @@ def ensureCached(toot, verbose=False, ignoreErrors=True, msg=None):
return None
else:
raise e
elif type(toot)==dict:
else: #if type(toot)==dict:
if type(toot["reblog"])==dict: toot=ensureCached(toot["reblog"])
if not "id" in toot: return toot
tid=toot["id"]
tid=str(toot["id"])
if tid in seen_toots: return toot
if not tid in tootbase:
tmp=copy.deepcopy(toot)
tmp["account"]=ensureCachedAcct(tmp["account"], verbose, ignoreErrors, msg)
tootbase[tid]=tmp
tb_dirty[int(tid[-2:])]=True
dirty(tid)
return tootbase[tid]
else:
statusMsg("Unexpected type of toot: "+str(type(toot)))
# else:
# statusMsg("Unexpected type of toot: "+str(type(toot)), True)

def dirty(tid):
global tb_dirty
tb_dirty[int(tid[-2:])]=True

def saveBase():
statusMsg("Saving tootbase...", False)
Expand Down

0 comments on commit b420ad9

Please sign in to comment.