mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Implement user import/export in server
This commit is contained in:
parent
4d63e6f577
commit
8573e5a80a
196 changed files with 5661 additions and 722 deletions
|
@ -7,6 +7,7 @@ import { VideoChannelSyncLatestScheduler } from '@server/lib/schedulers/video-ch
|
|||
import { VideoViewsBufferScheduler } from '@server/lib/schedulers/video-views-buffer-scheduler.js'
|
||||
import { VideoViewsManager } from '@server/lib/views/video-views-manager.js'
|
||||
import { authenticate, ensureUserHasRight } from '../../../middlewares/index.js'
|
||||
import { RemoveExpiredUserExportsScheduler } from '@server/lib/schedulers/remove-expired-user-exports-scheduler.js'
|
||||
|
||||
const debugRouter = express.Router()
|
||||
|
||||
|
@ -42,6 +43,7 @@ async function runCommand (req: express.Request, res: express.Response) {
|
|||
|
||||
const processors: { [id in SendDebugCommand['command']]: () => Promise<any> } = {
|
||||
'remove-dandling-resumable-uploads': () => RemoveDanglingResumableUploadsScheduler.Instance.execute(),
|
||||
'remove-expired-user-exports': () => RemoveExpiredUserExportsScheduler.Instance.execute(),
|
||||
'process-video-views-buffer': () => VideoViewsBufferScheduler.Instance.execute(),
|
||||
'process-video-viewers': () => VideoViewsManager.Instance.processViewerStats(),
|
||||
'process-update-videos-scheduler': () => UpdateVideosScheduler.Instance.execute(),
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import 'multer'
|
||||
import express from 'express'
|
||||
import { HttpStatusCode, UserRight } from '@peertube/peertube-models'
|
||||
import { logger } from '@server/helpers/logger.js'
|
||||
import { getServerActor } from '@server/models/application/application.js'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification.js'
|
||||
import { getFormattedObjects } from '../../../helpers/utils.js'
|
||||
import {
|
||||
addAccountInBlocklist,
|
||||
|
@ -105,15 +103,9 @@ async function blockAccount (req: express.Request, res: express.Response) {
|
|||
const serverActor = await getServerActor()
|
||||
const accountToBlock = res.locals.account
|
||||
|
||||
await addAccountInBlocklist(serverActor.Account.id, accountToBlock.id)
|
||||
await addAccountInBlocklist({ byAccountId: serverActor.Account.id, targetAccountId: accountToBlock.id, removeNotificationOfUserId: null })
|
||||
|
||||
UserNotificationModel.removeNotificationsOf({
|
||||
id: accountToBlock.id,
|
||||
type: 'account',
|
||||
forUserId: null // For all users
|
||||
}).catch(err => logger.error('Cannot remove notifications after an account mute.', { err }))
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function unblockAccount (req: express.Request, res: express.Response) {
|
||||
|
@ -121,7 +113,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
|
|||
|
||||
await removeAccountFromBlocklist(accountBlock)
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function listBlockedServers (req: express.Request, res: express.Response) {
|
||||
|
@ -142,15 +134,13 @@ async function blockServer (req: express.Request, res: express.Response) {
|
|||
const serverActor = await getServerActor()
|
||||
const serverToBlock = res.locals.server
|
||||
|
||||
await addServerInBlocklist(serverActor.Account.id, serverToBlock.id)
|
||||
await addServerInBlocklist({
|
||||
byAccountId: serverActor.Account.id,
|
||||
targetServerId: serverToBlock.id,
|
||||
removeNotificationOfUserId: null
|
||||
})
|
||||
|
||||
UserNotificationModel.removeNotificationsOf({
|
||||
id: serverToBlock.id,
|
||||
type: 'server',
|
||||
forUserId: null // For all users
|
||||
}).catch(err => logger.error('Cannot remove notifications after a server mute.', { err }))
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function unblockServer (req: express.Request, res: express.Response) {
|
||||
|
@ -158,5 +148,5 @@ async function unblockServer (req: express.Request, res: express.Response) {
|
|||
|
||||
await removeServerFromBlocklist(serverBlock)
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue