Skip to content

Conversation

@allouis
Copy link
Collaborator

@allouis allouis commented Apr 21, 2025

This doesn't clean up all places - we still have a lot of usage that should be cleaned up as we go

allouis added 3 commits April 21, 2025 09:46
ref https://linear.app/ghost/issue/AP-902

Since we now allow usernames to not be 'index' - but we want to
maintain 'index' as the identitifier in the path - we need to hardcode
these URL's to use 'index' in them. When we eventually have multiple
users per site, we will switch to the UUID for the identitifier in the path.

For now we want a single codepath, so we don't need to switch on index
vs uuid or index vs someother username. This keeps things simple and
easier to reason about when we do finally migrate to multiple users.
ref https://linear.app/ghost/issue/AP-902

This code path is no longer necessary as it's the old kv store inbox being
updated, and it refers to the old 'index' user which we want to clean up.
I haven't been able to remove all references to the old kv store inbox as the
tests often rely on it, but in this case they didn't
ref https://linear.app/ghost/issue/AP-902

This relied on the hardcoded 'index' via the DEFAULT_ACTOR_HANDLE. This also
stops the actor from being updated on each fetch for the site data.
@coderabbitai
Copy link

coderabbitai bot commented Apr 21, 2025

Walkthrough

This set of changes refactors several components related to ActivityPub account and site actor handling. The URL construction logic in the Account entity's getApId() and getApFollowers() methods was modified so that both methods now return URLs with a fixed index path segment, rather than dynamically including the username. Corresponding unit tests were updated to reflect these new expected URL formats.

Within the ActivityPub dispatching logic, conditional checks and user data retrieval related to reply targets in the handleAnnoucedCreate function were removed, simplifying the logic so that create activity IDs are always added to the inbox list without additional checks.

The getSiteDataHandler function was streamlined by removing the creation of a fedify context and all related calls to ensure or update the site actor. As a consequence, the updateSiteActor function and its associated imports were deleted from the codebase, along with its dedicated unit tests and related test utilities. No changes were made to the signatures or public declarations of exported entities except for the removal of the updateSiteActor function.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ec0607 and ad91f42.

📒 Files selected for processing (6)
  • src/account/account.entity.ts (2 hunks)
  • src/account/account.entity.unit.test.ts (2 hunks)
  • src/dispatchers.ts (0 hunks)
  • src/handlers.ts (0 hunks)
  • src/helpers/activitypub/actor.ts (1 hunks)
  • src/helpers/activitypub/actor.unit.test.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/handlers.ts
  • src/dispatchers.ts
🔇 Additional comments (6)
src/account/account.entity.unit.test.ts (2)

42-44: URL path now uses fixed 'index' instead of username

This change aligns with the refactoring to clean up 'index' usage in the codebase. The test now expects a fixed path with 'index' instead of dynamically including the username.


66-68: Followers URL now also uses fixed 'index' path

Consistent with the previous change, the followers URL path now also uses a fixed 'index' segment rather than dynamically including the username.

src/account/account.entity.ts (2)

139-142: Changed apId URL construction to use fixed 'index' path

The implementation now returns a URL with a fixed path segment 'index' instead of dynamically including the username. This aligns with the tests and helps clean up 'index' usage as mentioned in PR objectives.

Verify that consuming code is aware of this change in URL structure:

#!/bin/bash
# Search for code that might be relying on the previous URL format with username
rg -A 3 "activitypub/users/[^i]" --type ts

150-153: Changed followers URL construction to use fixed 'index' path

Similar to the apId change, this implementation now returns a URL with a fixed path segment 'index' instead of dynamically including the username.

src/helpers/activitypub/actor.unit.test.ts (1)

3-3: Simplified imports after removing updateSiteActor tests

The imports have been simplified, removing dependencies that were only needed for the updateSiteActor tests. This aligns with the cleanup mentioned in the PR objectives.

src/helpers/activitypub/actor.ts (1)

1-1: Simplified imports after removing updateSiteActor function

The imports have been reduced to only what's necessary after the removal of the updateSiteActor function. This cleanup aligns with the PR objectives.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@allouis allouis requested a review from mike182uk April 21, 2025 04:07
@allouis allouis requested a review from sagzy April 21, 2025 04:07
@allouis allouis requested review from vershwal and removed request for mike182uk and sagzy April 21, 2025 05:13
@allouis allouis merged commit 442e975 into main Apr 21, 2025
7 checks passed
@allouis allouis deleted the ap-902 branch April 21, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants