mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Update sequelize
This commit is contained in:
@@ -68,8 +68,8 @@ function updateCacheFile (
|
||||
|
||||
const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor)
|
||||
|
||||
redundancyModel.set('expires', attributes.expiresOn)
|
||||
redundancyModel.set('fileUrl', attributes.fileUrl)
|
||||
redundancyModel.expiresOn = attributes.expiresOn
|
||||
redundancyModel.fileUrl = attributes.fileUrl
|
||||
|
||||
return redundancyModel.save({ transaction: t })
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { getOrCreateVideoAndAccountAndChannel } from './videos'
|
||||
import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '../../helpers/custom-validators/activitypub/playlist'
|
||||
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
|
||||
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
||||
import { sequelizeTypescript } from '../../initializers/database'
|
||||
import { createPlaylistThumbnailFromUrl } from '../thumbnail'
|
||||
@@ -87,7 +86,8 @@ async function createOrUpdateVideoPlaylist (playlistObject: PlaylistObject, byAc
|
||||
}
|
||||
}
|
||||
|
||||
const [ playlist ] = await VideoPlaylistModel.upsert<VideoPlaylistModel>(playlistAttributes, { returning: true })
|
||||
// FIXME: sequelize typings
|
||||
const [ playlist ] = (await VideoPlaylistModel.upsert<VideoPlaylistModel>(playlistAttributes, { returning: true }) as any)
|
||||
|
||||
let accItems: string[] = []
|
||||
await crawlCollectionPage<string>(playlistObject.id, items => {
|
||||
@@ -156,7 +156,7 @@ export {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function resetVideoPlaylistElements (elementUrls: string[], playlist: VideoPlaylistModel) {
|
||||
const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = []
|
||||
const elementsToCreate: object[] = [] // FIXME: sequelize typings
|
||||
|
||||
await Bluebird.map(elementUrls, async elementUrl => {
|
||||
try {
|
||||
|
||||
@@ -37,7 +37,9 @@ async function processFollow (actor: ActorModel, targetActorURL: string) {
|
||||
if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) {
|
||||
logger.info('Rejecting %s because instance followers are disabled.', targetActor.url)
|
||||
|
||||
return sendReject(actor, targetActor)
|
||||
await sendReject(actor, targetActor)
|
||||
|
||||
return { actorFollow: undefined }
|
||||
}
|
||||
|
||||
const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({
|
||||
|
||||
@@ -120,9 +120,11 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
|
||||
|
||||
await actor.save({ transaction: t })
|
||||
|
||||
accountOrChannelInstance.set('name', actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername)
|
||||
accountOrChannelInstance.set('description', actorAttributesToUpdate.summary)
|
||||
accountOrChannelInstance.set('support', actorAttributesToUpdate.support)
|
||||
accountOrChannelInstance.name = actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername
|
||||
accountOrChannelInstance.description = actorAttributesToUpdate.summary
|
||||
|
||||
if (accountOrChannelInstance instanceof VideoChannelModel) accountOrChannelInstance.support = actorAttributesToUpdate.support
|
||||
|
||||
await accountOrChannelInstance.save({ transaction: t })
|
||||
})
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ async function addVideoComment (videoInstance: VideoModel, commentUrl: string) {
|
||||
const entry = await videoCommentActivityObjectToDBAttributes(videoInstance, actor, body)
|
||||
if (!entry) return { created: false }
|
||||
|
||||
const [ comment, created ] = await VideoCommentModel.upsert<VideoCommentModel>(entry, { returning: true })
|
||||
// FIXME: sequelize typings
|
||||
const [ comment, created ] = (await VideoCommentModel.upsert<VideoCommentModel>(entry, { returning: true }) as any)
|
||||
comment.Account = actor.Account
|
||||
comment.Video = videoInstance
|
||||
|
||||
|
||||
@@ -56,7 +56,10 @@ async function createRates (ratesUrl: string[], video: VideoModel, rate: VideoRa
|
||||
logger.info('Adding %d %s to video %s.', rateCounts, rate, video.uuid)
|
||||
|
||||
// This is "likes" and "dislikes"
|
||||
if (rateCounts !== 0) await video.increment(rate + 's', { by: rateCounts })
|
||||
if (rateCounts !== 0) {
|
||||
const field = rate === 'like' ? 'likes' : 'dislikes'
|
||||
await video.increment(field, { by: rateCounts })
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
ActivityPlaylistSegmentHashesObject,
|
||||
ActivityPlaylistUrlObject,
|
||||
ActivityUrlObject,
|
||||
ActivityVideoUrlObject, VideoCreate,
|
||||
ActivityVideoUrlObject,
|
||||
VideoState
|
||||
} from '../../../shared/index'
|
||||
import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
|
||||
@@ -45,7 +45,6 @@ import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
|
||||
import { Notifier } from '../notifier'
|
||||
import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
|
||||
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
|
||||
import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
|
||||
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
|
||||
import { VideoShareModel } from '../../models/video/video-share'
|
||||
import { VideoCommentModel } from '../../models/video/video-comment'
|
||||
@@ -312,7 +311,7 @@ async function updateVideoFromAP (options: {
|
||||
|
||||
// Update or add other one
|
||||
const upsertTasks = videoFileAttributes.map(a => {
|
||||
return VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t })
|
||||
return (VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t }) as any) // FIXME: sequelize typings
|
||||
.then(([ file ]) => file)
|
||||
})
|
||||
|
||||
@@ -335,7 +334,8 @@ async function updateVideoFromAP (options: {
|
||||
|
||||
// Update or add other one
|
||||
const upsertTasks = streamingPlaylistAttributes.map(a => {
|
||||
return VideoStreamingPlaylistModel.upsert<VideoStreamingPlaylistModel>(a, { returning: true, transaction: t })
|
||||
// FIXME: sequelize typings
|
||||
return (VideoStreamingPlaylistModel.upsert<VideoStreamingPlaylistModel>(a, { returning: true, transaction: t }) as any)
|
||||
.then(([ streamingPlaylist ]) => streamingPlaylist)
|
||||
})
|
||||
|
||||
@@ -594,7 +594,7 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
|
||||
throw new Error('Cannot find video files for ' + video.url)
|
||||
}
|
||||
|
||||
const attributes: FilteredModelAttributes<VideoFileModel>[] = []
|
||||
const attributes: object[] = [] // FIXME: add typings
|
||||
for (const fileUrl of fileUrls) {
|
||||
// Fetch associated magnet uri
|
||||
const magnet = videoObject.url.find(u => {
|
||||
@@ -629,7 +629,7 @@ function streamingPlaylistActivityUrlToDBAttributes (video: VideoModel, videoObj
|
||||
const playlistUrls = videoObject.url.filter(u => isAPStreamingPlaylistUrlObject(u)) as ActivityPlaylistUrlObject[]
|
||||
if (playlistUrls.length === 0) return []
|
||||
|
||||
const attributes: FilteredModelAttributes<VideoStreamingPlaylistModel>[] = []
|
||||
const attributes: object[] = [] // FIXME: add typings
|
||||
for (const playlistUrlObject of playlistUrls) {
|
||||
const segmentsSha256UrlObject = playlistUrlObject.tag
|
||||
.find(t => {
|
||||
|
||||
@@ -7,7 +7,6 @@ import { UserModel } from '../models/account/user'
|
||||
import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
|
||||
import { createVideoChannel } from './video-channel'
|
||||
import { VideoChannelModel } from '../models/video/video-channel'
|
||||
import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
|
||||
import { ActorModel } from '../models/activitypub/actor'
|
||||
import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
|
||||
import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
|
||||
@@ -73,7 +72,7 @@ async function createLocalAccountWithoutKeys (
|
||||
userId,
|
||||
applicationId,
|
||||
actorId: actorInstanceCreated.id
|
||||
} as FilteredModelAttributes<AccountModel>)
|
||||
})
|
||||
|
||||
const accountInstanceCreated = await accountInstance.save({ transaction: t })
|
||||
accountInstanceCreated.Actor = actorInstanceCreated
|
||||
|
||||
@@ -28,7 +28,7 @@ async function createVideoComment (obj: {
|
||||
videoId: obj.video.id,
|
||||
accountId: obj.account.id,
|
||||
url: 'fake url'
|
||||
}, { transaction: t, validate: false })
|
||||
}, { transaction: t, validate: false } as any) // FIXME: sequelize typings
|
||||
|
||||
comment.set('url', getVideoCommentActivityPubUrl(obj.video, comment))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user