diff --git a/packages/backend/src/remote/activitypub/kernel/announce/note.ts b/packages/backend/src/remote/activitypub/kernel/announce/note.ts index 6cdaa61662..acf8c84360 100644 --- a/packages/backend/src/remote/activitypub/kernel/announce/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/announce/note.ts @@ -32,8 +32,6 @@ export default async function ( // Interrupt if you block the announcement destination if (await shouldBlockInstance(extractDbHost(uri))) return; - const unlock = await getApLock(uri); - try { // Check if something with the same URI is already registered const exist = await fetchNote(uri); @@ -60,9 +58,10 @@ export default async function ( throw e; } - if (!(await Notes.isVisibleForMe(renote, actor.id))) - return "skip: invalid actor for this activity"; - + if (renote != null && !(await Notes.isVisibleForMe(renote, actor.id))) { + console.log("skip: invalid actor for this activity"); + return; + } logger.info(`Creating the (Re)Note: ${uri}`); const activityAudience = await parseAudience( @@ -79,6 +78,6 @@ export default async function ( uri, }); } finally { - unlock(); + await getApLock(uri); } } diff --git a/packages/backend/src/remote/activitypub/kernel/create/note.ts b/packages/backend/src/remote/activitypub/kernel/create/note.ts index 09c492730c..fe4cc0906f 100644 --- a/packages/backend/src/remote/activitypub/kernel/create/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/create/note.ts @@ -31,8 +31,6 @@ export default async function ( } } - const unlock = await getApLock(uri); - try { const exist = await fetchNote(note); if (exist) return "skip: note exists"; @@ -46,6 +44,6 @@ export default async function ( throw e; } } finally { - unlock(); + await getApLock(uri); } } diff --git a/packages/backend/src/remote/activitypub/kernel/delete/note.ts b/packages/backend/src/remote/activitypub/kernel/delete/note.ts index 69298e9175..b37f7d25f9 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/note.ts @@ -13,8 +13,6 @@ export default async function ( ): Promise { logger.info(`Deleting the Note: ${uri}`); - const unlock = await getApLock(uri); - try { const dbResolver = new DbResolver(); const note = await dbResolver.getNoteFromApId(uri); @@ -39,6 +37,6 @@ export default async function ( await deleteNode(actor, note); return "ok: note deleted"; } finally { - unlock(); + await getApLock(uri); } } diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 391f669f3f..8e305d7195 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -415,8 +415,6 @@ export async function resolveNote( `host ${extractDbHost(uri)} is blocked`, ); - const unlock = await getApLock(uri); - try { //#region Returns if already registered with this server const exist = await fetchNote(uri); @@ -439,7 +437,7 @@ export async function resolveNote( // Since the attached Note Object may be disguised, always specify the uri and fetch it from the server. return await createNote(uri, resolver, true); } finally { - unlock(); + await getApLock(uri); } } diff --git a/packages/backend/src/services/chart/core.ts b/packages/backend/src/services/chart/core.ts index 36fe373269..2fce4de91c 100644 --- a/packages/backend/src/services/chart/core.ts +++ b/packages/backend/src/services/chart/core.ts @@ -430,7 +430,6 @@ export default abstract class Chart { ? `${this.name}:${date}:${span}:${group}` : `${this.name}:${date}:${span}`; - const unlock = await getChartInsertLock(lockKey); try { // ロック内でもう1回チェックする const currentLog = (await repository.findOneBy({ @@ -466,7 +465,7 @@ export default abstract class Chart { return log; } finally { - unlock(); + await getChartInsertLock(lockKey); } }