Add workaround for Twitter's layout A/B testing

Fixes #110
This commit is contained in:
Zed
2020-01-19 08:34:32 +01:00
parent 6b16ad2ce0
commit ba57511a01
10 changed files with 43 additions and 21 deletions

View File

@@ -20,7 +20,8 @@ proc showRss*(req: Request; hostname: string; query: Query): Future[(string, str
(profile, timeline) =
await fetchSingleTimeline(names[0], after, getAgent(), query, media=false)
else:
timeline = await fetchMultiTimeline(names, after, getAgent(), query, media=false)
let multiQuery = query.getMultiQuery(names)
timeline = await getSearch[Tweet](multiQuery, after, getAgent(), media=false)
# this is kinda dumb
profile = Profile(
username: name,

View File

@@ -45,13 +45,11 @@ proc fetchSingleTimeline*(name, after, agent: string; query: Query;
if profile.username.len == 0: return
return (profile, timeline)
proc fetchMultiTimeline*(names: seq[string]; after, agent: string; query: Query;
media=true): Future[Timeline] {.async.} =
var q = query
q.fromUser = names
proc getMultiQuery*(q: Query; names: seq[string]): Query =
result = q
result.fromUser = names
if q.kind == posts and "replies" notin q.excludes:
q.excludes.add "replies"
return await getSearch[Tweet](q, after, agent, media)
result.excludes.add "replies"
proc get*(req: Request; key: string): string =
params(req).getOrDefault(key)
@@ -62,8 +60,10 @@ proc showTimeline*(request: Request; query: Query; cfg: Config; prefs: Prefs;
let names = getNames(request.get("name"))
if names.len != 1:
let timeline = await fetchMultiTimeline(names, after, agent, query)
let html = renderTweetSearch(timeline, prefs, getPath())
let
multiQuery = query.getMultiQuery(names)
timeline = await getSearch[Tweet](multiQuery, after, agent)
html = renderTweetSearch(timeline, prefs, getPath())
return renderMain(html, request, cfg, "Multi", rss=rss)
let