Conversation
- Update PostUpdatedEvent to implement SerializableEvent interface - Change event to store postId instead of full Post entity - Add toJSON() and fromJSON() methods for serialization - Update KnexPostRepository to emit event with postId - Update FediverseBridge to lookup Post from repository - Register PostUpdatedEvent with EventSerializer - Add unit tests for serialization/deserialization - Update existing tests to use new API Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
WalkthroughThis pull request refactors Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
| return this.postId; | ||
| } | ||
|
|
||
| static getName(): string { |
There was a problem hiding this comment.
@cursoragent lets add the non-static version like in the other events whilst we are here
|
|
||
| import { PostUpdatedEvent } from '@/post/post-updated.event'; | ||
|
|
||
| describe('PostUpdatedEvent', () => { |
There was a problem hiding this comment.
@cursoragent These tests should be consistent with the other events
There was a problem hiding this comment.
Restructured the PostUpdatedEvent tests to be consistent with other event tests:
- Added nested
describeblocks for each method (getName,getPostId,toJSON,fromJSON,round-trip serialization) - Added test case for
postIdbeingnull - Added round-trip serialization test
- Using
.toBe()instead of.toEqual()for primitive comparisons
Adds instance method that delegates to static method, consistent with other event classes like PostLikedEvent. Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
Use nested describe blocks for each method, consistent with PostLikedEvent and other event test files. Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/activitypub/fediverse-bridge.ts (1)
22-22: Repository injection pattern is consistent with codebase conventions.The guideline "repositories should not be used directly" is noted, but this pattern is established across the codebase:
NotificationEventService,PostInteractionCountsService,FeedUpdateService,GhostPostService,PostService, controllers, and other event handlers all inject and useKnexPostRepositorydirectly. There is noPostServicelayer providing an alternative.The implementation correctly guards against null and non-internal authors. The
postRepositoryparameter name matches the DI registration atsrc/configuration/registrations.ts:303, satisfying Awilix CLASSIC mode requirements.If the team intends to enforce repository abstraction, it would require broader refactoring beyond this change.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/activitypub/fediverse-bridge.ts` at line 22, The current use of KnexPostRepository in src/activitypub/fediverse-bridge.ts is consistent with the codebase pattern, so do not refactor to a service now; keep the constructor parameter named postRepository and continue injecting KnexPostRepository directly, ensure the existing null checks and non-internal author guards around usages remain intact, and make no change unless you plan a broader repository-abstraction refactor across NotificationEventService/PostInteractionCountsService/FeedUpdateService/GhostPostService/PostService and related DI registrations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/activitypub/fediverse-bridge.ts`:
- Line 22: The current use of KnexPostRepository in
src/activitypub/fediverse-bridge.ts is consistent with the codebase pattern, so
do not refactor to a service now; keep the constructor parameter named
postRepository and continue injecting KnexPostRepository directly, ensure the
existing null checks and non-internal author guards around usages remain intact,
and make no change unless you plan a broader repository-abstraction refactor
across
NotificationEventService/PostInteractionCountsService/FeedUpdateService/GhostPostService/PostService
and related DI registrations.


Refactor
PostUpdatedEventto implementSerializableEventto comply with ADR-0011.Linear Issue: BER-3164