Rework profile cache behavior, fix suspended cache

Fixes #480
This commit is contained in:
Zed
2022-01-16 20:32:45 +01:00
parent 23f87c115a
commit f3d6f53f6d
4 changed files with 20 additions and 21 deletions

View File

@@ -30,20 +30,13 @@ proc fetchTimeline*(after: string; query: Query; skipRail=false):
if profileId.len == 0:
profile = await getCachedProfile(name)
profileId = if profile.suspended: "s"
else: profile.id
if profileId.len > 0:
await cacheProfileId(profile.username, profileId)
profileId = profile.id
fetched = true
if profileId.len == 0 or profile.protected:
result[0] = profile
return
elif profileId == "s":
result[0] = Profile(username: name, suspended: true)
return
if profile.protected or profile.suspended:
return (profile, Timeline(), @[])
elif profileId.len == 0:
return (Profile(username: name), Timeline(), @[])
var rail: Future[PhotoRail]
if skipRail or profile.protected or query.kind == media: