|
@@ -12,11 +12,22 @@ export router_utils
|
|
|
export redis_cache, formatters, query, api
|
|
export redis_cache, formatters, query, api
|
|
|
export profile, timeline, status, about_account
|
|
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 =
|
|
proc getQuery*(request: Request; tab, name: string; prefs: Prefs): Query =
|
|
|
let view = request.params.getOrDefault("view")
|
|
let view = request.params.getOrDefault("view")
|
|
|
case tab
|
|
case tab
|
|
|
of "with_replies":
|
|
of "with_replies":
|
|
|
result = getReplyQuery(name)
|
|
result = getReplyQuery(name)
|
|
|
|
|
+ of "articles":
|
|
|
|
|
+ result = getArticlesQuery(name)
|
|
|
of "media":
|
|
of "media":
|
|
|
result = getMediaQuery(name)
|
|
result = getMediaQuery(name)
|
|
|
result.view =
|
|
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 posts: await getGraphUserTweets(userId, TimelineKind.tweets, after)
|
|
|
of replies: await getGraphUserTweets(userId, TimelineKind.replies, after)
|
|
of replies: await getGraphUserTweets(userId, TimelineKind.replies, after)
|
|
|
of media: await getGraphUserTweets(userId, TimelineKind.media, 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))
|
|
else: Profile(tweets: await getGraphTweetSearch(query, after))
|
|
|
|
|
|
|
|
result.user = await user
|
|
result.user = await user
|
|
@@ -172,7 +184,9 @@ proc createTimelineRouter*(cfg: Config) =
|
|
|
cond '.' notin @"name"
|
|
cond '.' notin @"name"
|
|
|
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login", "intent", "i"]
|
|
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login", "intent", "i"]
|
|
|
cond @"name".allCharsInSet({'a'..'z', 'A'..'Z', '0'..'9', '_', ','})
|
|
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
|
|
let
|
|
|
prefs = requestPrefs()
|
|
prefs = requestPrefs()
|
|
|
after = getCursor()
|
|
after = getCursor()
|
|
@@ -196,15 +210,8 @@ proc createTimelineRouter*(cfg: Config) =
|
|
|
profile.tweets.beginning = true
|
|
profile.tweets.beginning = true
|
|
|
resp $renderTimelineTweets(profile.tweets, prefs, getPath())
|
|
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 =
|
|
let rss =
|
|
|
- if not rssEnabled:
|
|
|
|
|
|
|
+ if not cfg.tabRssEnabled(@"tab"):
|
|
|
""
|
|
""
|
|
|
elif @"tab".len == 0:
|
|
elif @"tab".len == 0:
|
|
|
"/$1/rss" % @"name"
|
|
"/$1/rss" % @"name"
|