mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Move models to typescript-sequelize
This commit is contained in:
parent
c893d4514e
commit
3fd3ab2d34
150 changed files with 3676 additions and 5074 deletions
|
@ -1,31 +1,34 @@
|
|||
import { Transaction } from 'sequelize'
|
||||
import { ActivityUpdate } from '../../../../shared/models/activitypub/activity'
|
||||
import { database as db } from '../../../initializers'
|
||||
import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
|
||||
import { ActivityUpdate } from '../../../../shared/models/activitypub'
|
||||
import { AccountModel } from '../../../models/account/account'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||
import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
import { getUpdateActivityPubUrl } from '../url'
|
||||
import { broadcastToFollowers, getAudience } from './misc'
|
||||
|
||||
async function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
|
||||
async function sendUpdateVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
|
||||
const byAccount = videoChannel.Account
|
||||
|
||||
const url = getUpdateActivityPubUrl(videoChannel.url, videoChannel.updatedAt.toISOString())
|
||||
const videoChannelObject = videoChannel.toActivityPubObject()
|
||||
const data = await updateActivityData(url, byAccount, videoChannelObject, t)
|
||||
|
||||
const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t)
|
||||
const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
|
||||
accountsInvolved.push(byAccount)
|
||||
|
||||
return broadcastToFollowers(data, byAccount, accountsInvolved, t)
|
||||
}
|
||||
|
||||
async function sendUpdateVideo (video: VideoInstance, t: Transaction) {
|
||||
async function sendUpdateVideo (video: VideoModel, t: Transaction) {
|
||||
const byAccount = video.VideoChannel.Account
|
||||
|
||||
const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString())
|
||||
const videoObject = video.toActivityPubObject()
|
||||
const data = await updateActivityData(url, byAccount, videoObject, t)
|
||||
|
||||
const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t)
|
||||
const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t)
|
||||
accountsInvolved.push(byAccount)
|
||||
|
||||
return broadcastToFollowers(data, byAccount, accountsInvolved, t)
|
||||
|
@ -40,9 +43,9 @@ export {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function updateActivityData (url: string, byAccount: AccountInstance, object: any, t: Transaction) {
|
||||
async function updateActivityData (url: string, byAccount: AccountModel, object: any, t: Transaction): Promise<ActivityUpdate> {
|
||||
const { to, cc } = await getAudience(byAccount, t)
|
||||
const activity: ActivityUpdate = {
|
||||
return {
|
||||
type: 'Update',
|
||||
id: url,
|
||||
actor: byAccount.url,
|
||||
|
@ -50,6 +53,4 @@ async function updateActivityData (url: string, byAccount: AccountInstance, obje
|
|||
cc,
|
||||
object
|
||||
}
|
||||
|
||||
return activity
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue