diff options
Diffstat (limited to 'server/lib/activitypub/actors/updater.ts')
-rw-r--r-- | server/lib/activitypub/actors/updater.ts | 24 |
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 @@ | |||
1 | import { resetSequelizeInstance } from '@server/helpers/database-utils' | 1 | import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils' |
2 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
3 | import { sequelizeTypescript } from '@server/initializers/database' | ||
4 | import { VideoChannelModel } from '@server/models/video/video-channel' | 3 | import { VideoChannelModel } from '@server/models/video/video-channel' |
5 | import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models' | 4 | import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models' |
6 | import { ActivityPubActor, ActorImageType } from '@shared/models' | 5 | import { 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) { |