1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Cleanup model types

This commit is contained in:
Chocobozzz 2019-08-20 13:52:49 +02:00
parent 96ca24f00e
commit 0283eaac2a
No known key found for this signature in database
GPG key ID: 583A612D890159BE
50 changed files with 696 additions and 349 deletions

View file

@ -24,15 +24,17 @@ import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor'
import { sequelizeTypescript } from '../../initializers/database'
import {
MAccount,
MAccountDefault,
MActor,
MActorAccountChannelId,
MActorAccountChannelIdActor,
MActorAccountId,
MActorDefault,
MActorFull,
MActorFullActor,
MActorId,
MActorAccountChannelIdActor,
MChannel,
MActorFullActor, MAccountActorDefault, MChannelActorDefault, MChannelActorAccountDefault
MChannelAccountDefault
} from '../../typings/models'
// Set account keys, this could be long so process after the account creation and do not block the client
@ -374,12 +376,11 @@ function saveActorAndServerAndModelIfNotExist (
})
if (actorCreated.type === 'Person' || actorCreated.type === 'Application') {
actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountActorDefault
actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountDefault
actorCreated.Account.Actor = actorCreated
} else if (actorCreated.type === 'Group') { // Video channel
actorCreated.VideoChannel = await saveVideoChannel(actorCreated, result, ownerActor, t) as MChannelActorAccountDefault
actorCreated.VideoChannel.Actor = actorCreated
actorCreated.VideoChannel.Account = ownerActor.Account
const channel = await saveVideoChannel(actorCreated, result, ownerActor, t)
actorCreated.VideoChannel = Object.assign(channel, { Actor: actorCreated, Account: ownerActor.Account })
}
actorCreated.Server = server

View file

@ -7,7 +7,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { Notifier } from '../../notifier'
import { logger } from '../../../helpers/logger'
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
import { MActorSignature, MVideoAccountAllFiles } from '../../../typings/models'
import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models'
async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
const { activity, byActor: actorAnnouncer } = options
@ -28,7 +28,7 @@ export {
async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) {
const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
let video: MVideoAccountAllFiles
let video: MVideoAccountLightBlacklistAllFiles
let videoCreated: boolean
try {

View file

@ -11,7 +11,7 @@ import { Notifier } from '../../notifier'
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
import { createOrUpdateVideoPlaylist } from '../playlist'
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
import { MActorSignature, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../../typings/models'
import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models'
async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
const { activity, byActor } = options
@ -81,7 +81,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc
if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url)
let video: MVideoAccountAllFiles
let video: MVideoAccountLightBlacklistAllFiles
let created: boolean
let comment: MCommentOwnerVideo
try {

View file

@ -7,7 +7,7 @@ import { getOrCreateActorAndServerAndModel } from './actor'
import { getOrCreateVideoAndAccountAndChannel } from './videos'
import * as Bluebird from 'bluebird'
import { checkUrlsSameHost } from '../../helpers/activitypub'
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../typings/models/video'
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../typings/models/video'
type ResolveThreadParams = {
url: string,
@ -15,7 +15,7 @@ type ResolveThreadParams = {
isVideo?: boolean,
commentCreated?: boolean
}
type ResolveThreadResult = Promise<{ video: MVideoAccountAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
async function addVideoComments (commentUrls: string[]) {
return Bluebird.map(commentUrls, commentUrl => {

View file

@ -58,7 +58,7 @@ import {
MChannelDefault,
MChannelId,
MVideo,
MVideoAccountAllFiles,
MVideoAccountLightBlacklistAllFiles,
MVideoAccountLight,
MVideoAP,
MVideoAPWithoutCaption,
@ -213,19 +213,19 @@ function getOrCreateVideoAndAccountAndChannel (options: {
syncParam?: SyncParam,
fetchType?: 'all',
allowRefresh?: boolean
}): Promise<{ video: MVideoAccountAllFiles, created: boolean, autoBlacklisted?: boolean }>
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles, created: boolean, autoBlacklisted?: boolean }>
function getOrCreateVideoAndAccountAndChannel (options: {
videoObject: { id: string } | string,
syncParam?: SyncParam,
fetchType?: VideoFetchByUrlType,
allowRefresh?: boolean
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
async function getOrCreateVideoAndAccountAndChannel (options: {
videoObject: { id: string } | string,
syncParam?: SyncParam,
fetchType?: VideoFetchByUrlType,
allowRefresh?: boolean // true by default
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
// Default params
const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
const fetchType = options.fetchType || 'all'
@ -263,7 +263,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
}
async function updateVideoFromAP (options: {
video: MVideoAccountAllFiles,
video: MVideoAccountLightBlacklistAllFiles,
videoObject: VideoTorrentObject,
account: MAccountActor,
channel: MChannelDefault,
@ -420,7 +420,7 @@ async function refreshVideoIfNeeded (options: {
// We need more attributes if the argument video was fetched with not enough joints
const video = options.fetchedType === 'all'
? options.video as MVideoAccountAllFiles
? options.video as MVideoAccountLightBlacklistAllFiles
: await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
try {