Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/activitypub/fediverse-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Reject,
Update,
} from '@fedify/fedify';
import type { Logger } from '@logtape/logtape';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Logger DI: type‑only import looks good; verify Awilix CLASSIC registration name is logger.

Type import is correct. Ensure the container registers a dependency named exactly logger (CLASSIC injection is name‑based) and update tests/mocks accordingly.

Also applies to: 28-33


🏁 Script executed:

#!/bin/bash
# Verify Awilix registration for `logger`
rg -nP --type=ts -C3 '\bregister\(\{[^}]*\blogger\b'
rg -nP --type=ts -C3 '\blogger\s*:\s*(?:asClass|asFunction|asValue)\('
# Also list DI/container files for manual inspection
fd -t f -e ts -a | rg -nP '(awilix|container|di|ioc)'

Length of output: 847


🏁 Script executed:

#!/bin/bash
# Inspect Awilix container registration for `logger`
rg -nP 'register\(\s*\{' -C5 src/configuration/container.ts
rg -nP '\blogger\s*:' -C3 src/configuration/container.ts
# Check if loadModules is used instead of register
rg -nP 'loadModules' -C5 src/configuration/container.ts

Length of output: 0


Register logger in the DI container
No logger registration found in src/configuration/container.ts—add a classic Awilix registration named exactly logger (e.g.

container.register({  
  logger: asClass(LogTapeLogger).singleton()  
});

) and update tests/mocks accordingly.

🤖 Prompt for AI Agents
In src/activitypub/fediverse-bridge.ts around line 11 the code expects a DI
binding named "logger" but no registration exists; open
src/configuration/container.ts and add a classic Awilix registration named
exactly logger (e.g. register the real LogTape logger with
asClass(...).singleton()) so the container provides the dependency, then update
test setup/mocks to register a mock or stub logger under the same name (or use
container.register in tests with asValue(mockLogger)) so all imports that expect
Logger resolve correctly.

import { v4 as uuidv4 } from 'uuid';

import type { Account } from '@/account/account.entity';
Expand All @@ -28,6 +29,7 @@ export class FediverseBridge {
private readonly events: EventEmitter,
private readonly fedifyContextFactory: FedifyContextFactory,
private readonly accountService: AccountService,
private readonly logger: Logger,
) {}

async init() {
Expand Down Expand Up @@ -76,14 +78,25 @@ export class FediverseBridge {
) {
const ctx = this.fedifyContextFactory.getFedifyContext();

await ctx.sendActivity(
{ username: account.username },
'followers',
activity,
{
preferSharedInbox: true,
},
);
try {
await ctx.sendActivity(
{ username: account.username },
'followers',
activity,
{
preferSharedInbox: true,
},
);
} catch (error) {
// The action succeeded, but federation fails. This needs to be handled
// gracefully to avoid 500 responses to the user, in case of synchronous
// federation (e.g. no message queue is used).
this.logger.error('Failed to federate activity to followers: {error}', {
accountId: account.id,
accountUsername: account.username,
error,
});
}
}

private async handlePostCreated(event: PostCreatedEvent) {
Expand Down
Loading