-
-
Notifications
You must be signed in to change notification settings - Fork 23
Moved AccountUpdatedEvent into Entity #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ref https://linear.app/ghost/issue/PROD-1986 We don't want to emit an AccountUpdatedEvent for every time an entity is saved, we only want to do it when we have actually updated the data. This may also have knock-on effects where an account was updated, but in the context of another accounts request, and the event handler was attempting to call `sendActivity` but the keys used were from the wrong context, so it fails.
|
""" WalkthroughThis change introduces an instance method Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code Graph Analysis (2)src/account/account.entity.unit.test.ts (2)
src/activitypub/fediverse-bridge.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (9)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/account/account-updated.event.ts (1)
8-10: Question the necessity of duplicate getName() methods.Both static and instance methods return the same value
'account.updated'. This duplication seems unnecessary and could lead to confusion about which method to use.Is there a specific reason for having both? Consider removing one to maintain simplicity and follow DRY principles.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/account/account-updated.event.ts(1 hunks)src/account/account.entity.ts(2 hunks)src/account/account.repository.knex.ts(0 hunks)
💤 Files with no reviewable changes (1)
- src/account/account.repository.knex.ts
🧰 Additional context used
🧠 Learnings (1)
src/account/account.entity.ts (1)
Learnt from: allouis
PR: TryGhost/ActivityPub#566
File: src/account/account.entity.ts:110-123
Timestamp: 2025-04-24T10:41:15.124Z
Learning: In the Account entity's `updateProfile` method, the current implementation using a helper function that checks for undefined values is type-safe at runtime, even though TypeScript might not perfectly infer this due to the function's return type declaration.
🧬 Code Graph Analysis (1)
src/account/account.entity.ts (1)
src/account/account-updated.event.ts (1)
AccountUpdatedEvent(3-17)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build, Test and Push
🔇 Additional comments (2)
src/account/account.entity.ts (2)
7-7: LGTM: Import addition is appropriate.The import is correctly added to support the new event emission functionality.
146-146: LGTM: Explicit return type improves code clarity.Adding the explicit return type
Accountimproves type safety and code documentation.
| if ( | ||
| account.username !== this.username || | ||
| account.name !== this.name || | ||
| account.bio !== this.bio || | ||
| account.avatarUrl !== this.avatarUrl || | ||
| account.bannerImageUrl !== this.bannerImageUrl | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, just a thought, we already do this check in the account service:
https://github.com/TryGhost/ActivityPub/blob/main/src/account/account.service.ts#L613-L623
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I think I should remove the check there then!
ref https://linear.app/ghost/issue/PROD-1986
We don't want to emit an AccountUpdatedEvent for every time an entity is saved, we only want to do it when we have actually updated the data. This may also have knock-on effects where an account was updated, but in the context of another accounts request, and the event handler was attempting to call
sendActivitybut the keys used were from the wrong context, so it fails.