diff options
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r-- | server/controllers/api/users/me.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 7ab089713..009cf42b7 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -10,7 +10,7 @@ import { CONFIG } from '../../../initializers/config' | |||
10 | import { MIMETYPES } from '../../../initializers/constants' | 10 | import { MIMETYPES } from '../../../initializers/constants' |
11 | import { sequelizeTypescript } from '../../../initializers/database' | 11 | import { sequelizeTypescript } from '../../../initializers/database' |
12 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 12 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
13 | import { updateActorAvatarFile } from '../../../lib/avatar' | 13 | import { deleteActorAvatarFile, updateActorAvatarFile } from '../../../lib/avatar' |
14 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' | 14 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' |
15 | import { | 15 | import { |
16 | asyncMiddleware, | 16 | asyncMiddleware, |
@@ -89,6 +89,11 @@ meRouter.post('/me/avatar/pick', | |||
89 | asyncRetryTransactionMiddleware(updateMyAvatar) | 89 | asyncRetryTransactionMiddleware(updateMyAvatar) |
90 | ) | 90 | ) |
91 | 91 | ||
92 | meRouter.delete('/me/avatar', | ||
93 | authenticate, | ||
94 | asyncRetryTransactionMiddleware(deleteMyAvatar) | ||
95 | ) | ||
96 | |||
92 | // --------------------------------------------------------------------------- | 97 | // --------------------------------------------------------------------------- |
93 | 98 | ||
94 | export { | 99 | export { |
@@ -225,7 +230,16 @@ async function updateMyAvatar (req: express.Request, res: express.Response) { | |||
225 | 230 | ||
226 | const userAccount = await AccountModel.load(user.Account.id) | 231 | const userAccount = await AccountModel.load(user.Account.id) |
227 | 232 | ||
228 | const avatar = await updateActorAvatarFile(avatarPhysicalFile, userAccount) | 233 | const avatar = await updateActorAvatarFile(userAccount, avatarPhysicalFile) |
229 | 234 | ||
230 | return res.json({ avatar: avatar.toFormattedJSON() }) | 235 | return res.json({ avatar: avatar.toFormattedJSON() }) |
231 | } | 236 | } |
237 | |||
238 | async function deleteMyAvatar (req: express.Request, res: express.Response) { | ||
239 | const user = res.locals.oauth.token.user | ||
240 | |||
241 | const userAccount = await AccountModel.load(user.Account.id) | ||
242 | await deleteActorAvatarFile(userAccount) | ||
243 | |||
244 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | ||
245 | } | ||