+async function listAccountChannelsSync (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,
+ search: req.query.search
+ }
+
+ const resultList = await VideoChannelSyncModel.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'
+ )
+
+ return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query)))
+}
+
+async function listAccountRatings (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+
+ const resultList = await AccountVideoRateModel.listByAccountForApi({
+ accountId: account.id,
+ start: req.query.start,
+ count: req.query.count,
+ sort: req.query.sort,
+ type: req.query.rating
+ })
+ return res.json(getFormattedObjects(resultList.data, resultList.total))
+}
+
+async function listAccountFollowers (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+
+ const channels = await VideoChannelModel.listAllByAccount(account.id)
+ const actorIds = [ account.actorId ].concat(channels.map(c => c.actorId))