aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/actors/updater.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/actors/updater.ts')
-rw-r--r--server/lib/activitypub/actors/updater.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/server/lib/activitypub/actors/updater.ts b/server/lib/activitypub/actors/updater.ts
index 471688f11..fb880a767 100644
--- a/server/lib/activitypub/actors/updater.ts
+++ b/server/lib/activitypub/actors/updater.ts
@@ -1,6 +1,5 @@
1import { resetSequelizeInstance } from '@server/helpers/database-utils' 1import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils'
2import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
3import { sequelizeTypescript } from '@server/initializers/database'
4import { VideoChannelModel } from '@server/models/video/video-channel' 3import { VideoChannelModel } from '@server/models/video/video-channel'
5import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models' 4import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models'
6import { ActivityPubActor, ActorImageType } from '@shared/models' 5import { ActivityPubActor, ActorImageType } from '@shared/models'
@@ -32,22 +31,23 @@ export class APActorUpdater {
32 const bannerInfo = getImageInfoFromObject(this.actorObject, ActorImageType.BANNER) 31 const bannerInfo = getImageInfoFromObject(this.actorObject, ActorImageType.BANNER)
33 32
34 try { 33 try {
35 await sequelizeTypescript.transaction(async t => { 34 await this.updateActorInstance(this.actor, this.actorObject)
36 await this.updateActorInstance(this.actor, this.actorObject)
37 35
38 await updateActorImageInstance(this.actor, ActorImageType.AVATAR, avatarInfo, t) 36 this.accountOrChannel.name = this.actorObject.name || this.actorObject.preferredUsername
39 await updateActorImageInstance(this.actor, ActorImageType.BANNER, bannerInfo, t) 37 this.accountOrChannel.description = this.actorObject.summary
40
41 await this.actor.save({ transaction: t })
42
43 this.accountOrChannel.name = this.actorObject.name || this.actorObject.preferredUsername
44 this.accountOrChannel.description = this.actorObject.summary
45 38
46 if (this.accountOrChannel instanceof VideoChannelModel) this.accountOrChannel.support = this.actorObject.support 39 if (this.accountOrChannel instanceof VideoChannelModel) this.accountOrChannel.support = this.actorObject.support
47 40
41 await runInReadCommittedTransaction(async t => {
42 await this.actor.save({ transaction: t })
48 await this.accountOrChannel.save({ transaction: t }) 43 await this.accountOrChannel.save({ transaction: t })
49 }) 44 })
50 45
46 await runInReadCommittedTransaction(async t => {
47 await updateActorImageInstance(this.actor, ActorImageType.AVATAR, avatarInfo, t)
48 await updateActorImageInstance(this.actor, ActorImageType.BANNER, bannerInfo, t)
49 })
50
51 logger.info('Remote account %s updated', this.actorObject.url) 51 logger.info('Remote account %s updated', this.actorObject.url)
52 } catch (err) { 52 } catch (err) {
53 if (this.actor !== undefined && this.actorFieldsSave !== undefined) { 53 if (this.actor !== undefined && this.actorFieldsSave !== undefined) {