From 1ea7da819e5bfae7b443ed722c18c4165d101439 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Wed, 13 Jan 2021 09:12:55 +0100 Subject: 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 --- server/lib/activitypub/actor.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 52547536c..086d656f9 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -199,6 +199,19 @@ async function updateActorAvatarInstance (actor: MActorDefault, info: AvatarInfo return actor } +async function deleteActorAvatarInstance (actor: MActorDefault, t: Transaction) { + try { + await actor.Avatar.destroy({ transaction: t }) + } catch (err) { + logger.error('Cannot remove old avatar of actor %s.', actor.url, { err }) + } + + actor.avatarId = null + actor.Avatar = null + + return actor +} + async function fetchActorTotalItems (url: string) { const options = { uri: url, @@ -337,6 +350,7 @@ export { fetchActorTotalItems, getAvatarInfoIfExists, updateActorInstance, + deleteActorAvatarInstance, refreshActorIfNeeded, updateActorAvatarInstance, addFetchOutboxJob -- cgit v1.2.3