aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-13 09:16:15 +0100
committerGitHub <noreply@github.com>2021-01-13 09:16:15 +0100
commitd8b34ee55b654912f86bb8b472d391ced8c28f64 (patch)
treeefa2b8ac36c00fa6e9b5af3f13e54a47bc7a7701 /server/models
parent22078471fbe5a4dea6177bd1fa19da1cf887679e (diff)
downloadPeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.tar.gz
PeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.tar.zst
PeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.zip
Allow user to search through their watch history (#3576)
* allow user to search through their watch history * add tests for search in watch history * Update client/src/app/shared/shared-main/users/user-history.service.ts
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/user-video-history.ts3
-rw-r--r--server/models/video/video.ts4
2 files changed, 5 insertions, 2 deletions
diff --git a/server/models/account/user-video-history.ts b/server/models/account/user-video-history.ts
index 45171fc60..6be1d65ea 100644
--- a/server/models/account/user-video-history.ts
+++ b/server/models/account/user-video-history.ts
@@ -55,10 +55,11 @@ export class UserVideoHistoryModel extends Model {
55 }) 55 })
56 User: UserModel 56 User: UserModel
57 57
58 static listForApi (user: MUserAccountId, start: number, count: number) { 58 static listForApi (user: MUserAccountId, start: number, count: number, search?: string) {
59 return VideoModel.listForApi({ 59 return VideoModel.listForApi({
60 start, 60 start,
61 count, 61 count,
62 search,
62 sort: '-"userVideoHistory"."updatedAt"', 63 sort: '-"userVideoHistory"."updatedAt"',
63 nsfw: null, // All 64 nsfw: null, // All
64 includeLocalVideos: true, 65 includeLocalVideos: true,
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index abf823d4b..5027e980d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1087,6 +1087,7 @@ export class VideoModel extends Model {
1087 user?: MUserAccountId 1087 user?: MUserAccountId
1088 historyOfUser?: MUserId 1088 historyOfUser?: MUserId
1089 countVideos?: boolean 1089 countVideos?: boolean
1090 search?: string
1090 }) { 1091 }) {
1091 if ((options.filter === 'all-local' || options.filter === 'all') && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) { 1092 if ((options.filter === 'all-local' || options.filter === 'all') && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) {
1092 throw new Error('Try to filter all-local but no user has not the see all videos right') 1093 throw new Error('Try to filter all-local but no user has not the see all videos right')
@@ -1123,7 +1124,8 @@ export class VideoModel extends Model {
1123 includeLocalVideos: options.includeLocalVideos, 1124 includeLocalVideos: options.includeLocalVideos,
1124 user: options.user, 1125 user: options.user,
1125 historyOfUser: options.historyOfUser, 1126 historyOfUser: options.historyOfUser,
1126 trendingDays 1127 trendingDays,
1128 search: options.search
1127 } 1129 }
1128 1130
1129 return VideoModel.getAvailableForApi(queryOptions, options.countVideos) 1131 return VideoModel.getAvailableForApi(queryOptions, options.countVideos)