-async function getAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
- const account: AccountModel = res.locals.account
-
- const resultList = await VideoModel.listForApi(
- req.query.start as number,
- req.query.count as number,
- req.query.sort as VideoSortField,
- isNSFWHidden(res),
- null,
- false,
- account.id
+async function listAccountChannels (req: express.Request, res: express.Response) {
+ const options = {
+ accountId: res.locals.account.id,
+ start: req.query.start,
+ count: req.query.count,
+ sort: req.query.sort,
+ withStats: req.query.withStats,
+ search: req.query.search
+ }
+
+ const resultList = await VideoChannelModel.listByAccountForAPI(options)
+
+ return res.json(getFormattedObjects(resultList.data, resultList.total))
+}
+
+async function listAccountPlaylists (req: express.Request, res: express.Response) {
+ const serverActor = await getServerActor()
+
+ // Allow users to see their private/unlisted video playlists
+ let listMyPlaylists = false
+ if (res.locals.oauth && res.locals.oauth.token.User.Account.id === res.locals.account.id) {
+ listMyPlaylists = true
+ }
+
+ const resultList = await VideoPlaylistModel.listForApi({
+ search: req.query.search,
+ followerActorId: serverActor.id,
+ start: req.query.start,
+ count: req.query.count,
+ sort: req.query.sort,
+ accountId: res.locals.account.id,
+ listMyPlaylists,
+ type: req.query.playlistType
+ })
+
+ return res.json(getFormattedObjects(resultList.data, resultList.total))
+}
+
+async function listAccountVideos (req: express.Request, res: express.Response) {
+ const serverActor = await getServerActor()
+
+ const account = res.locals.account
+
+ const displayOnlyForFollower = isUserAbleToSearchRemoteURI(res)
+ ? null
+ : {
+ actorId: serverActor.id,
+ orLocalVideos: true
+ }
+
+ const countVideos = getCountVideos(req)
+ const query = pickCommonVideoQuery(req.query)
+
+ const apiOptions = await Hooks.wrapObject({
+ ...query,
+
+ displayOnlyForFollower,
+ nsfw: buildNSFWFilter(res, query.nsfw),
+ accountId: account.id,
+ user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
+ countVideos
+ }, 'filter:api.accounts.videos.list.params')
+
+ const resultList = await Hooks.wrapPromiseFun(
+ VideoModel.listForApi,
+ apiOptions,
+ 'filter:api.accounts.videos.list.result'