Always show retweets unless excluded in search
This commit is contained in:
parent
0e58c36bae
commit
33f0ab0ba5
4 changed files with 9 additions and 16 deletions
|
@ -3,7 +3,6 @@ import strutils, strformat, sequtils, tables, uri
|
||||||
import types
|
import types
|
||||||
|
|
||||||
const
|
const
|
||||||
# separators = @["AND", "OR"]
|
|
||||||
validFilters* = @[
|
validFilters* = @[
|
||||||
"media", "images", "twimg", "videos",
|
"media", "images", "twimg", "videos",
|
||||||
"native_video", "consumer_video", "pro_video",
|
"native_video", "consumer_video", "pro_video",
|
||||||
|
@ -30,9 +29,6 @@ proc initQuery*(pms: Table[string, string]; name=""): Query =
|
||||||
if name.len > 0:
|
if name.len > 0:
|
||||||
result.fromUser = name.split(",")
|
result.fromUser = name.split(",")
|
||||||
|
|
||||||
if @"e-nativeretweets".len == 0:
|
|
||||||
result.includes.add "nativeretweets"
|
|
||||||
|
|
||||||
proc getMediaQuery*(name: string): Query =
|
proc getMediaQuery*(name: string): Query =
|
||||||
Query(
|
Query(
|
||||||
kind: media,
|
kind: media,
|
||||||
|
@ -44,11 +40,10 @@ proc getMediaQuery*(name: string): Query =
|
||||||
proc getReplyQuery*(name: string): Query =
|
proc getReplyQuery*(name: string): Query =
|
||||||
Query(
|
Query(
|
||||||
kind: replies,
|
kind: replies,
|
||||||
includes: @["nativeretweets"],
|
|
||||||
fromUser: @[name]
|
fromUser: @[name]
|
||||||
)
|
)
|
||||||
|
|
||||||
proc genQueryParam*(query: Query; rewriteReplies=true): string =
|
proc genQueryParam*(query: Query): string =
|
||||||
var
|
var
|
||||||
filters: seq[string]
|
filters: seq[string]
|
||||||
param: string
|
param: string
|
||||||
|
@ -68,6 +63,9 @@ proc genQueryParam*(query: Query; rewriteReplies=true): string =
|
||||||
if i < query.fromUser.high:
|
if i < query.fromUser.high:
|
||||||
param &= "OR "
|
param &= "OR "
|
||||||
|
|
||||||
|
if "nativeretweets" notin query.excludes:
|
||||||
|
param &= "include:nativeretweets "
|
||||||
|
|
||||||
for f in query.filters:
|
for f in query.filters:
|
||||||
filters.add "filter:" & f
|
filters.add "filter:" & f
|
||||||
for e in query.excludes:
|
for e in query.excludes:
|
||||||
|
|
|
@ -21,8 +21,9 @@ proc showRss*(req: Request; hostname: string; query: Query): Future[Rss] {.async
|
||||||
(profile, timeline) =
|
(profile, timeline) =
|
||||||
await fetchSingleTimeline(after, query, skipRail=true)
|
await fetchSingleTimeline(after, query, skipRail=true)
|
||||||
else:
|
else:
|
||||||
let multiQuery = query.getMultiQuery(names)
|
var q = query
|
||||||
timeline = await getSearch[Tweet](multiQuery, after)
|
q.fromUser = names
|
||||||
|
timeline = await getSearch[Tweet](q, after)
|
||||||
# this is kinda dumb
|
# this is kinda dumb
|
||||||
profile = Profile(
|
profile = Profile(
|
||||||
username: name,
|
username: name,
|
||||||
|
|
|
@ -13,7 +13,7 @@ export search
|
||||||
proc createSearchRouter*(cfg: Config) =
|
proc createSearchRouter*(cfg: Config) =
|
||||||
router search:
|
router search:
|
||||||
get "/search/?":
|
get "/search/?":
|
||||||
if @"q".len > 200:
|
if @"q".len > 500:
|
||||||
resp Http400, showError("Search input too long.", cfg)
|
resp Http400, showError("Search input too long.", cfg)
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
@ -73,12 +73,6 @@ proc fetchSingleTimeline*(after: string; query: Query; skipRail=false):
|
||||||
|
|
||||||
return (profile, timeline, await rail)
|
return (profile, timeline, await rail)
|
||||||
|
|
||||||
proc getMultiQuery*(q: Query; names: seq[string]): Query =
|
|
||||||
result = q
|
|
||||||
result.fromUser = names
|
|
||||||
if q.kind == posts and "replies" notin q.excludes:
|
|
||||||
result.excludes.add "replies"
|
|
||||||
|
|
||||||
proc get*(req: Request; key: string): string =
|
proc get*(req: Request; key: string): string =
|
||||||
params(req).getOrDefault(key)
|
params(req).getOrDefault(key)
|
||||||
|
|
||||||
|
@ -118,7 +112,7 @@ proc createTimelineRouter*(cfg: Config) =
|
||||||
|
|
||||||
var query = request.getQuery(@"tab", @"name")
|
var query = request.getQuery(@"tab", @"name")
|
||||||
if names.len != 1:
|
if names.len != 1:
|
||||||
query = query.getMultiQuery(names)
|
query.fromUser = names
|
||||||
|
|
||||||
if @"scroll".len > 0:
|
if @"scroll".len > 0:
|
||||||
if query.fromUser.len != 1:
|
if query.fromUser.len != 1:
|
||||||
|
|
Loading…
Reference in a new issue