summaryrefslogtreecommitdiffstats
path: root/src/invidious.cr
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-09-16 22:14:51 -0500
committerOmar Roth <omarroth@hotmail.com>2018-09-16 22:14:51 -0500
commit0a4e9e62526fbae2e0d139a9e53f8712f7e5d6a0 (patch)
tree6ee5cdc6f63ecef588f6cb7a5608a5eb1684db0e /src/invidious.cr
parent9619d3f1bc7ad768a51935d31b4512d7aa0b79b3 (diff)
downloadinvidious-0a4e9e62526fbae2e0d139a9e53f8712f7e5d6a0.tar.gz
invidious-0a4e9e62526fbae2e0d139a9e53f8712f7e5d6a0.tar.bz2
invidious-0a4e9e62526fbae2e0d139a9e53f8712f7e5d6a0.zip
Properly filter user's subscriptions in search
Diffstat (limited to 'src/invidious.cr')
-rw-r--r--src/invidious.cr11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 36c104dc..a5a5a229 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -430,6 +430,13 @@ get "/search" do |env|
page = env.params.query["page"]?.try &.to_i?
page ||= 1
+ user = env.get? "user"
+ if user
+ user = user.as(User)
+ ucids = user.subscriptions
+ end
+ ucids ||= [] of String
+
channel = nil
date = ""
duration = ""
@@ -467,8 +474,8 @@ get "/search" do |env|
to_tsvector(channel_videos.title) ||
to_tsvector(channel_videos.author)
as document
- FROM channel_videos
- ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;", search_query, (page - 1) * 20, as: ChannelVideo)
+ FROM channel_videos WHERE ucid IN (#{arg_array(ucids, 3)})
+ ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;", [search_query, (page - 1) * 20] + ucids, as: ChannelVideo)
count = videos.size
else
search_params = build_search_params(sort: sort, date: date, content_type: "video",