Skip to content
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

refactor(apub): move service to user #39

Merged
merged 2 commits into from
May 17, 2024
Merged

refactor(apub): move service to user #39

merged 2 commits into from
May 17, 2024

Conversation

kwaa
Copy link
Member

@kwaa kwaa commented May 17, 2024

Summary by CodeRabbit

  • Refactor

    • Renamed Service to User across various modules to improve clarity and consistency.
    • Adjusted import paths and references to align with the new naming conventions.
    • Updated function signatures and variable names to reflect the changes in entity names.
  • New Features

    • Introduced new structures such as UserType, UserAttachment, and UserImage to enhance user representation and functionality.
  • Documentation

    • Updated documentation to reflect the new entity names and structures.

@kwaa kwaa added the enhancement New feature or request label May 17, 2024
@kwaa kwaa added this to the 0.2 [celluloid] milestone May 17, 2024
Copy link

coderabbitai bot commented May 17, 2024

Walkthrough

The recent updates focus on renaming and restructuring entities related to the User in various modules. The Service entity was replaced with User, and imports and references were adjusted accordingly. This change spans multiple files, affecting function signatures, variable assignments, and module exports. The goal is to streamline the codebase and enhance clarity by using consistent naming conventions for user-related entities.

Changes

Files Change Summary
crates/api_apub/src/users/user.rs Updated imports and function signatures to use User instead of Service.
crates/api_mastodon/src/entities/account.rs, crates/api_mastodon/src/entities/status.rs Renamed Service to User and adjusted related function signatures and variable names.
crates/apub/src/actors/mod.rs, crates/apub/src/actors/db_user.rs, crates/apub/src/actors/user.rs Restructured modules, renamed Service to User, and updated public exports and entity references.
crates/apub/src/actors/user_attachment.rs, crates/apub/src/actors/user_image.rs Introduced UserAttachment and UserImage structs with associated methods and functionality.
crates/apub/tests/actors.rs Updated import statements and function calls to use User instead of Service.
crates/openapi/src/apidoc.rs Changed references from Service to User in the OpenAPI documentation.

In code's vast realm, a change took flight,
From Service to User, a name so bright.
With modules aligned and imports set right,
Our functions now gleam in the new light.
Attachments and images, all in their place,
The codebase now runs with elegant grace.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

@coderabbitai coderabbitai bot left a 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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 58b0255 and 96d208d.
Files selected for processing (10)
  • crates/api_apub/src/users/user.rs (4 hunks)
  • crates/api_mastodon/src/entities/account.rs (3 hunks)
  • crates/api_mastodon/src/entities/status.rs (2 hunks)
  • crates/apub/src/actors/db_user.rs (5 hunks)
  • crates/apub/src/actors/mod.rs (1 hunks)
  • crates/apub/src/actors/user.rs (1 hunks)
  • crates/apub/src/actors/user_attachment.rs (1 hunks)
  • crates/apub/src/actors/user_image.rs (1 hunks)
  • crates/apub/tests/actors.rs (1 hunks)
  • crates/openapi/src/apidoc.rs (1 hunks)
Additional comments not posted (13)
crates/apub/tests/actors.rs (1)

1-6: The test function correctly uses the updated User entity.

crates/apub/src/actors/mod.rs (1)

3-10: The module declarations and public exports are correctly updated to reflect the new User entity structure.

crates/apub/src/actors/user_image.rs (1)

1-25: The UserImage struct is correctly defined with appropriate serialization settings and schema annotations.

crates/api_mastodon/src/entities/status.rs (1)

Line range hint 35-44: The Status struct and the from_json method are correctly updated to use the User entity.

crates/apub/src/actors/user_attachment.rs (1)

1-51: The UserAttachment struct and its methods are correctly defined with appropriate serialization settings and schema annotations.

crates/api_mastodon/src/entities/account.rs (1)

Line range hint 25-51: The Account struct and its methods are correctly updated to use the User entity.

crates/api_apub/src/users/user.rs (1)

Line range hint 10-81: The user function is correctly updated to use the User entity.

crates/apub/src/actors/user.rs (1)

1-86: The User struct and the UserType enum are correctly defined with appropriate serialization settings and schema annotations.

crates/openapi/src/apidoc.rs (1)

41-43: The updates to the OpenAPI schema components align well with the renaming strategy outlined in the PR. Ensure that these changes are consistently applied across all related files.

Verification successful

The renaming from Service to User has been consistently applied across the codebase. The remaining occurrences of Service and ServiceType are legitimate uses in different contexts, such as ActivityPub and NodeInfoServices.

  • crates/apub/src/actors/user.rs: ServiceType and Service are used in the context of ActivityPub.
  • crates/apub/src/actors/db_user.rs: ServiceType and Service are used in the context of ActivityPub.
  • crates/nodeinfo/src/schema.rs: NodeInfoServices is a distinct concept.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the renaming from `Service` to `User` is consistently applied across all related files.

# Test: Search for the old `Service` naming in the project. Expect: No occurrences of `Service` related to the renamed entities.
rg --type rust --glob '!migrations/*' 'Service'

Length of output: 907



Script:

#!/bin/bash
# Description: Examine the context of occurrences of `Service` to determine if they are related to the renaming from `Service` to `User`.

# Display lines around the matches in `crates/apub/src/actors/user.rs` and `crates/apub/src/actors/db_user.rs` to understand the context.
rg --type rust --glob '!migrations/*' -C 3 'Service' crates/apub/src/actors/user.rs crates/apub/src/actors/db_user.rs

Length of output: 2589



Script:

#!/bin/bash
# Description: Verify if `ServiceType` and `Service` are intended to remain as is or if they should be renamed.

# Search for the definition and usages of `ServiceType` and `Service` in the codebase.
rg --type rust --glob '!migrations/*' 'ServiceType' 
rg --type rust --glob '!migrations/*' 'Service'

Length of output: 1258

crates/apub/src/actors/db_user.rs (4)

11-11: The renaming of the import to PreludeUser is a good strategy to avoid naming conflicts with the User entity defined in this crate.


47-47: The updates to the Object trait implementation for ApubUser are correctly using the new User entity names and the PreludeUser for database interactions.

Also applies to: 57-57, 64-64


100-100: The use of the on_conflict clause in the insert method is a prudent choice to handle potential primary key conflicts safely.


123-123: The use of UserType::ServiceType(ServiceType::Service) seems inconsistent with the renaming strategy. Please verify if this is intended or if it should be updated to reflect the new terminology.

Verification successful

The definitions of the UserType and ServiceType enums confirm that the usage of UserType::ServiceType(ServiceType::Service) is consistent with the current terminology in the codebase. The UserType enum includes a variant ServiceType that takes a ServiceType enum as its parameter, and ServiceType is used correctly in this context.

  • UserType enum includes:

    • ServiceType(ServiceType)
    • PersonType(PersonType)
  • ServiceType is used as expected within the UserType enum.

Therefore, the usage of UserType::ServiceType(ServiceType::Service) is correct and consistent with the defined enums.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `UserType::ServiceType` in the context of the renaming strategy.

# Test: Search for the usage of `UserType::ServiceType`. Expect: Consistent usage or updates to match the new terminology.
rg --type rust 'UserType::ServiceType'

Length of output: 135



Script:

#!/bin/bash
# Description: Find the definition of `UserType` enum and its variants.

# Search for the definition of `UserType` enum.
ast-grep --lang rust --pattern 'enum UserType { $$$ }'

# Search for the definition of `ServiceType` enum.
ast-grep --lang rust --pattern 'enum ServiceType { $$$ }'

# Search for the usage of `ServiceType::Service`.
rg --type rust 'ServiceType::Service'

Length of output: 251



Script:

#!/bin/bash
# Description: Refine the search for the definition of `UserType` and `ServiceType` enums and their variants.

# Search for the definition of `UserType` enum.
rg --type rust 'enum UserType'

# Search for the definition of `ServiceType` enum.
rg --type rust 'enum ServiceType'

# Search for any usage of `UserType`.
rg --type rust 'UserType'

# Search for any usage of `ServiceType`.
rg --type rust 'ServiceType'

Length of output: 853



Script:

#!/bin/bash
# Description: Extract the definitions of `UserType` and `ServiceType` enums from `crates/apub/src/actors/user.rs`.

# Extract the definition of `UserType` enum.
rg --type rust --context 10 'pub enum UserType' crates/apub/src/actors/user.rs

# Extract the definition of `ServiceType` enum.
rg --type rust --context 10 'ServiceType' crates/apub/src/actors/user.rs

Length of output: 1469

crates/apub/src/actors/db_user.rs Show resolved Hide resolved
@kwaa kwaa merged commit 3dd1813 into main May 17, 2024
1 check passed
@kwaa kwaa deleted the refactor/user branch May 17, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant