-import * as Bluebird from 'bluebird'
import { join } from 'path'
import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize'
import {
Table,
UpdatedAt
} from 'sequelize-typescript'
+import { v4 as uuidv4 } from 'uuid'
import { MAccountId, MChannelId } from '@server/types/models'
import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
]
},
[ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => {
-
let whereActor: WhereOptions = {}
const whereAnd: WhereOptions[] = []
[Op.and]: whereAnd
}
- const accountScope = {
- method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ]
- }
-
return {
where,
include: [
{
- model: AccountModel.scope(accountScope),
+ model: AccountModel.scope({
+ method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ]
+ }),
required: true
},
{
}
]
})
-export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
+export class VideoPlaylistModel extends Model {
@CreatedAt
createdAt: Date
})
}
- static listPlaylistIdsOf (accountId: number, videoIds: number[]): Bluebird<MVideoPlaylistIdWithElements[]> {
+ static listPlaylistIdsOf (accountId: number, videoIds: number[]): Promise<MVideoPlaylistIdWithElements[]> {
const query = {
attributes: [ 'id' ],
where: {
static doesPlaylistExist (url: string) {
const query = {
- attributes: [],
+ attributes: [ 'id' ],
where: {
url
}
.then(e => !!e)
}
- static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFullSummary> {
+ static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFullSummary> {
const where = buildWhereIdOrUUID(id)
const query = {
.findOne(query)
}
- static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFull> {
+ static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFull> {
const where = buildWhereIdOrUUID(id)
const query = {
.findOne(query)
}
- static loadByUrlAndPopulateAccount (url: string): Bluebird<MVideoPlaylistAccountThumbnail> {
+ static loadByUrlAndPopulateAccount (url: string): Promise<MVideoPlaylistAccountThumbnail> {
const query = {
where: {
url
generateThumbnailName () {
const extension = '.jpg'
- return 'playlist-' + this.uuid + extension
+ return 'playlist-' + uuidv4() + extension
}
getThumbnailUrl () {