diff options
author | Wicklow <wicklow@framasoft.org> | 2023-02-24 16:21:26 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-02-25 15:47:48 +0100 |
commit | c0687c91b9cf185c36e477ab30266c779f792ee1 (patch) | |
tree | 5c917b6b87b38eb89620ed21b114ac67c96a71d9 /server/controllers/api | |
parent | d41f4a6dc69d098e9dc9173b7e1a586695ef7b97 (diff) | |
download | PeerTube-c0687c91b9cf185c36e477ab30266c779f792ee1.tar.gz PeerTube-c0687c91b9cf185c36e477ab30266c779f792ee1.tar.zst PeerTube-c0687c91b9cf185c36e477ab30266c779f792ee1.zip |
Add server hooks for listing subscription
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users/my-subscriptions.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 6c64e99a7..6ba8ba597 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -30,6 +30,7 @@ import { | |||
30 | } from '../../../middlewares/validators' | 30 | } from '../../../middlewares/validators' |
31 | import { ActorFollowModel } from '../../../models/actor/actor-follow' | 31 | import { ActorFollowModel } from '../../../models/actor/actor-follow' |
32 | import { VideoModel } from '../../../models/video/video' | 32 | import { VideoModel } from '../../../models/video/video' |
33 | import { Hooks } from '@server/lib/plugins/hooks' | ||
33 | 34 | ||
34 | const mySubscriptionsRouter = express.Router() | 35 | const mySubscriptionsRouter = express.Router() |
35 | 36 | ||
@@ -170,7 +171,7 @@ async function getUserSubscriptionVideos (req: express.Request, res: express.Res | |||
170 | const countVideos = getCountVideos(req) | 171 | const countVideos = getCountVideos(req) |
171 | const query = pickCommonVideoQuery(req.query) | 172 | const query = pickCommonVideoQuery(req.query) |
172 | 173 | ||
173 | const resultList = await VideoModel.listForApi({ | 174 | const apiOptions = await Hooks.wrapObject({ |
174 | ...query, | 175 | ...query, |
175 | 176 | ||
176 | displayOnlyForFollower: { | 177 | displayOnlyForFollower: { |
@@ -180,7 +181,13 @@ async function getUserSubscriptionVideos (req: express.Request, res: express.Res | |||
180 | nsfw: buildNSFWFilter(res, query.nsfw), | 181 | nsfw: buildNSFWFilter(res, query.nsfw), |
181 | user, | 182 | user, |
182 | countVideos | 183 | countVideos |
183 | }) | 184 | }, 'filter:api.user.me.subscription-videos.list.params') |
185 | |||
186 | const resultList = await Hooks.wrapPromiseFun( | ||
187 | VideoModel.listForApi, | ||
188 | apiOptions, | ||
189 | 'filter:api.user.me.subscription-videos.list.result' | ||
190 | ) | ||
184 | 191 | ||
185 | return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query))) | 192 | return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query))) |
186 | } | 193 | } |