import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
import { VideoModel } from './video'
import { VideoPlaylistModel } from './video-playlist'
+import { CONFIG } from '@server/initializers/config'
export enum ScopeNames {
FOR_API = 'FOR_API',
for (const handle of options.handles || []) {
const [ preferredUsername, host ] = handle.split('@')
- if (!host) {
+ if (!host || host === WEBSERVER.HOST) {
or.push({
'$Actor.preferredUsername$': preferredUsername,
'$Actor.serverId$': null
})
}
- static listByAccount (options: {
+ static listByAccountForAPI (options: {
accountId: number
start: number
count: number
})
}
+ static listAllByAccount (accountId: number) {
+ const query = {
+ limit: CONFIG.VIDEO_CHANNELS.MAX_PER_USER,
+ include: [
+ {
+ attributes: [],
+ model: AccountModel,
+ where: {
+ id: accountId
+ },
+ required: true
+ }
+ ]
+ }
+
+ return VideoChannelModel.findAll(query)
+ }
+
static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> {
return VideoChannelModel.unscoped()
.scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])
return this.Actor.isOutdated()
}
- setAsUpdated (transaction: Transaction) {
+ setAsUpdated (transaction?: Transaction) {
return setAsUpdated('videoChannel', this.id, transaction)
}
}