diff options
| author | Marie <github@yuugi.dev> | 2025-05-08 09:17:07 +0000 |
|---|---|---|
| committer | Marie <github@yuugi.dev> | 2025-05-08 09:17:07 +0000 |
| commit | a72610c8d6b9dba03a0270f6c9aa86c76cbb8bd9 (patch) | |
| tree | ee30fb9fbe48e0b4711e3cd51f4484e9aac0ce66 /packages/backend/src/core/NotePiningService.ts | |
| parent | merge: Respect "enable favicon notification dot" setting (resolves #1048) (!988) (diff) | |
| parent | reorder relay activities to avoid delivery race condition (diff) | |
| download | sharkey-a72610c8d6b9dba03a0270f6c9aa86c76cbb8bd9.tar.gz sharkey-a72610c8d6b9dba03a0270f6c9aa86c76cbb8bd9.tar.bz2 sharkey-a72610c8d6b9dba03a0270f6c9aa86c76cbb8bd9.zip | |
merge: Reorder relay activities to avoid delivery race condition (resolves #989) (!986)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/986
Closes #989
Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
Diffstat (limited to 'packages/backend/src/core/NotePiningService.ts')
| -rw-r--r-- | packages/backend/src/core/NotePiningService.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts index d38b48b65d..6ab7268254 100644 --- a/packages/backend/src/core/NotePiningService.ts +++ b/packages/backend/src/core/NotePiningService.ts @@ -49,7 +49,7 @@ export class NotePiningService { * @param noteId */ @bindThis - public async addPinned(user: { id: MiUser['id']; host: MiUser['host']; }, noteId: MiNote['id']) { + public async addPinned(user: MiUser, noteId: MiNote['id']) { // Fetch pinee const note = await this.notesRepository.findOneBy({ id: noteId, @@ -78,7 +78,7 @@ export class NotePiningService { // Deliver to remote followers if (this.userEntityService.isLocalUser(user) && !note.localOnly && ['public', 'home'].includes(note.visibility)) { - this.deliverPinnedChange(user.id, note.id, true); + this.deliverPinnedChange(user, note.id, true); } } @@ -88,7 +88,7 @@ export class NotePiningService { * @param noteId */ @bindThis - public async removePinned(user: { id: MiUser['id']; host: MiUser['host']; }, noteId: MiNote['id']) { + public async removePinned(user: MiUser, noteId: MiNote['id']) { // Fetch unpinee const note = await this.notesRepository.findOneBy({ id: noteId, @@ -106,22 +106,19 @@ export class NotePiningService { // Deliver to remote followers if (this.userEntityService.isLocalUser(user) && !note.localOnly && ['public', 'home'].includes(note.visibility)) { - this.deliverPinnedChange(user.id, noteId, false); + this.deliverPinnedChange(user, noteId, false); } } @bindThis - public async deliverPinnedChange(userId: MiUser['id'], noteId: MiNote['id'], isAddition: boolean) { - const user = await this.usersRepository.findOneBy({ id: userId }); - if (user == null) throw new Error('user not found'); - + public async deliverPinnedChange(user: MiUser, noteId: MiNote['id'], isAddition: boolean) { if (!this.userEntityService.isLocalUser(user)) return; const target = `${this.config.url}/users/${user.id}/collections/featured`; const item = `${this.config.url}/notes/${noteId}`; const content = this.apRendererService.addContext(isAddition ? this.apRendererService.renderAdd(user, target, item) : this.apRendererService.renderRemove(user, target, item)); - this.apDeliverManagerService.deliverToFollowers(user, content); - this.relayService.deliverToRelays(user, content); + await this.apDeliverManagerService.deliverToFollowers(user, content); + await this.relayService.deliverToRelays(user, content); } } |