mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Basic video redundancy implementation
This commit is contained in:
parent
a651038487
commit
c48e82b5e0
77 changed files with 1667 additions and 287 deletions
|
@ -17,8 +17,6 @@ import {
|
|||
import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/models/search'
|
||||
import { getOrCreateActorAndServerAndModel, getOrCreateVideoAndAccountAndChannel } from '../../lib/activitypub'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { User } from '../../../shared/models/users'
|
||||
import { CONFIG } from '../../initializers/constants'
|
||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
|
||||
|
||||
|
|
|
@ -96,6 +96,11 @@ async function removeFollow (req: express.Request, res: express.Response, next:
|
|||
await sequelizeTypescript.transaction(async t => {
|
||||
if (follow.state === 'accepted') await sendUndoFollow(follow, t)
|
||||
|
||||
// Disable redundancy on unfollowed instances
|
||||
const server = follow.ActorFollowing.Server
|
||||
server.redundancyAllowed = false
|
||||
await server.save({ transaction: t })
|
||||
|
||||
await follow.destroy({ transaction: t })
|
||||
})
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import * as express from 'express'
|
||||
import { serverFollowsRouter } from './follows'
|
||||
import { statsRouter } from './stats'
|
||||
import { serverRedundancyRouter } from './redundancy'
|
||||
|
||||
const serverRouter = express.Router()
|
||||
|
||||
serverRouter.use('/', serverFollowsRouter)
|
||||
serverRouter.use('/', serverRedundancyRouter)
|
||||
serverRouter.use('/', statsRouter)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
32
server/controllers/api/server/redundancy.ts
Normal file
32
server/controllers/api/server/redundancy.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import * as express from 'express'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
|
||||
import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
|
||||
import { ServerModel } from '../../../models/server/server'
|
||||
|
||||
const serverRedundancyRouter = express.Router()
|
||||
|
||||
serverRedundancyRouter.put('/redundancy/:host',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
|
||||
asyncMiddleware(updateServerRedundancyValidator),
|
||||
asyncMiddleware(updateRedundancy)
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
serverRedundancyRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function updateRedundancy (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const server = res.locals.server as ServerModel
|
||||
|
||||
server.redundancyAllowed = req.body.redundancyAllowed
|
||||
|
||||
await server.save()
|
||||
|
||||
return res.sendStatus(204)
|
||||
}
|
|
@ -112,7 +112,7 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
|
|||
|
||||
// We send the video abuse to the origin server
|
||||
if (videoInstance.isOwned() === false) {
|
||||
await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance, t)
|
||||
await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance)
|
||||
}
|
||||
|
||||
auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseInstance.toFormattedJSON()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue