mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Type toFormattedJSON
This commit is contained in:
parent
0283eaac2a
commit
1ca9f7c3f7
54 changed files with 401 additions and 147 deletions
|
@ -23,15 +23,12 @@ import { createReqFiles } from '../../../helpers/express-utils'
|
|||
import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
|
||||
import { updateAvatarValidator } from '../../../middlewares/validators/avatar'
|
||||
import { updateActorAvatarFile } from '../../../lib/avatar'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
|
||||
import { VideoImportModel } from '../../../models/video/video-import'
|
||||
import { AccountModel } from '../../../models/account/account'
|
||||
import { CONFIG } from '../../../initializers/config'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { sendVerifyUserEmail } from '../../../lib/user'
|
||||
|
||||
const auditLogger = auditLoggerFactory('users-me')
|
||||
|
||||
const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
|
||||
|
||||
const meRouter = express.Router()
|
||||
|
@ -165,8 +162,6 @@ async function deleteMe (req: express.Request, res: express.Response) {
|
|||
|
||||
await user.destroy()
|
||||
|
||||
auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})))
|
||||
|
||||
return res.sendStatus(204)
|
||||
}
|
||||
|
||||
|
@ -175,7 +170,6 @@ async function updateMe (req: express.Request, res: express.Response) {
|
|||
let sendVerificationEmail = false
|
||||
|
||||
const user = res.locals.oauth.token.user
|
||||
const oldUserAuditView = new UserAuditView(user.toFormattedJSON({}))
|
||||
|
||||
if (body.password !== undefined) user.password = body.password
|
||||
if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
|
||||
|
@ -204,8 +198,6 @@ async function updateMe (req: express.Request, res: express.Response) {
|
|||
await userAccount.save({ transaction: t })
|
||||
|
||||
await sendUpdateActor(userAccount, t)
|
||||
|
||||
auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})), oldUserAuditView)
|
||||
})
|
||||
|
||||
if (sendVerificationEmail === true) {
|
||||
|
@ -218,13 +210,10 @@ async function updateMe (req: express.Request, res: express.Response) {
|
|||
async function updateMyAvatar (req: express.Request, res: express.Response) {
|
||||
const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
|
||||
const user = res.locals.oauth.token.user
|
||||
const oldUserAuditView = new UserAuditView(user.toFormattedJSON({}))
|
||||
|
||||
const userAccount = await AccountModel.load(user.Account.id)
|
||||
|
||||
const avatar = await updateActorAvatarFile(avatarPhysicalFile, userAccount)
|
||||
|
||||
auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})), oldUserAuditView)
|
||||
|
||||
return res.json({ avatar: avatar.toFormattedJSON() })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue