mirror of
https://github.com/zedeus/nitter
synced 2026-09-06 07:09:31 +00:00
parent
a68b57629a
commit
8142bab1a9
13 changed files with 103 additions and 39 deletions
|
|
@ -106,24 +106,16 @@ proc createRssRouter*(cfg: Config) =
|
|||
|
||||
get "/@name/@tab/rss":
|
||||
cond '.' notin @"name"
|
||||
cond @"tab" in ["with_replies", "media", "search"]
|
||||
let rssEnabled = case @"tab"
|
||||
of "with_replies": cfg.enableRSSUserReplies
|
||||
of "media": cfg.enableRSSUserMedia
|
||||
of "search": cfg.enableRSSSearch
|
||||
else: false
|
||||
if not rssEnabled:
|
||||
cond @"tab" in ["with_replies", "media", "search", "articles"]
|
||||
# articles can't be approximated by search, so multi-user is unsupported
|
||||
cond not (@"tab" == "articles" and ',' in @"name")
|
||||
if not cfg.tabRssEnabled(@"tab"):
|
||||
resp Http403, showError("RSS feed is disabled", cfg)
|
||||
let
|
||||
prefs = requestPrefs()
|
||||
name = @"name"
|
||||
tab = @"tab"
|
||||
query =
|
||||
case tab
|
||||
of "with_replies": getReplyQuery(name)
|
||||
of "media": getMediaQuery(name)
|
||||
of "search": initQuery(params(request), name=name)
|
||||
else: Query(fromUser: @[name])
|
||||
query = request.getQuery(tab, name, prefs)
|
||||
|
||||
let searchKey = if tab != "search": ""
|
||||
else: ":" & $hash(genQueryUrl(query))
|
||||
|
|
|
|||
|
|
@ -12,11 +12,22 @@ export router_utils
|
|||
export redis_cache, formatters, query, api
|
||||
export profile, timeline, status, about_account
|
||||
|
||||
proc tabRssEnabled*(cfg: Config; tab: string): bool =
|
||||
case tab
|
||||
of "": cfg.enableRSSUserTweets
|
||||
of "with_replies": cfg.enableRSSUserReplies
|
||||
of "media": cfg.enableRSSUserMedia
|
||||
of "articles": cfg.enableRSSUserArticles
|
||||
of "search": cfg.enableRSSSearch
|
||||
else: false
|
||||
|
||||
proc getQuery*(request: Request; tab, name: string; prefs: Prefs): Query =
|
||||
let view = request.params.getOrDefault("view")
|
||||
case tab
|
||||
of "with_replies":
|
||||
result = getReplyQuery(name)
|
||||
of "articles":
|
||||
result = getArticlesQuery(name)
|
||||
of "media":
|
||||
result = getMediaQuery(name)
|
||||
result.view =
|
||||
|
|
@ -64,6 +75,7 @@ proc fetchProfile*(after: string; query: Query; skipRail=false): Future[Profile]
|
|||
of posts: await getGraphUserTweets(userId, TimelineKind.tweets, after)
|
||||
of replies: await getGraphUserTweets(userId, TimelineKind.replies, after)
|
||||
of media: await getGraphUserTweets(userId, TimelineKind.media, after)
|
||||
of QueryKind.articles: await getGraphUserTweets(userId, TimelineKind.articles, after)
|
||||
else: Profile(tweets: await getGraphTweetSearch(query, after))
|
||||
|
||||
result.user = await user
|
||||
|
|
@ -172,7 +184,9 @@ proc createTimelineRouter*(cfg: Config) =
|
|||
cond '.' notin @"name"
|
||||
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login", "intent", "i"]
|
||||
cond @"name".allCharsInSet({'a'..'z', 'A'..'Z', '0'..'9', '_', ','})
|
||||
cond @"tab" in ["with_replies", "media", "search", ""]
|
||||
cond @"tab" in ["with_replies", "media", "search", "articles", ""]
|
||||
# articles can't be approximated by search, so multi-user is unsupported
|
||||
cond not (@"tab" == "articles" and ',' in @"name")
|
||||
let
|
||||
prefs = requestPrefs()
|
||||
after = getCursor()
|
||||
|
|
@ -196,15 +210,8 @@ proc createTimelineRouter*(cfg: Config) =
|
|||
profile.tweets.beginning = true
|
||||
resp $renderTimelineTweets(profile.tweets, prefs, getPath())
|
||||
|
||||
let rssEnabled =
|
||||
if @"tab".len == 0: cfg.enableRSSUserTweets
|
||||
elif @"tab" == "with_replies": cfg.enableRSSUserReplies
|
||||
elif @"tab" == "media": cfg.enableRSSUserMedia
|
||||
elif @"tab" == "search": cfg.enableRSSSearch
|
||||
else: false
|
||||
|
||||
let rss =
|
||||
if not rssEnabled:
|
||||
if not cfg.tabRssEnabled(@"tab"):
|
||||
""
|
||||
elif @"tab".len == 0:
|
||||
"/$1/rss" % @"name"
|
||||
|
|
|
|||
Loading…
Reference in a new issue