1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

add ability to remove one's avatar for account and channels (#3467)

* add ability to remove one's avatar for account and channels

* add ability to remove one's avatar for account and channels

* only display avatar edition options after input change
This commit is contained in:
Rigel Kent 2021-01-13 09:12:55 +01:00 committed by GitHub
parent 75dd1b641f
commit 1ea7da819e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 207 additions and 27 deletions

View file

@ -10,7 +10,7 @@ import { CONFIG } from '../../../initializers/config'
import { MIMETYPES } from '../../../initializers/constants'
import { sequelizeTypescript } from '../../../initializers/database'
import { sendUpdateActor } from '../../../lib/activitypub/send'
import { updateActorAvatarFile } from '../../../lib/avatar'
import { deleteActorAvatarFile, updateActorAvatarFile } from '../../../lib/avatar'
import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user'
import {
asyncMiddleware,
@ -89,6 +89,11 @@ meRouter.post('/me/avatar/pick',
asyncRetryTransactionMiddleware(updateMyAvatar)
)
meRouter.delete('/me/avatar',
authenticate,
asyncRetryTransactionMiddleware(deleteMyAvatar)
)
// ---------------------------------------------------------------------------
export {
@ -225,7 +230,16 @@ async function updateMyAvatar (req: express.Request, res: express.Response) {
const userAccount = await AccountModel.load(user.Account.id)
const avatar = await updateActorAvatarFile(avatarPhysicalFile, userAccount)
const avatar = await updateActorAvatarFile(userAccount, avatarPhysicalFile)
return res.json({ avatar: avatar.toFormattedJSON() })
}
async function deleteMyAvatar (req: express.Request, res: express.Response) {
const user = res.locals.oauth.token.user
const userAccount = await AccountModel.load(user.Account.id)
await deleteActorAvatarFile(userAccount)
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}