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

add mentions in content and notify members when mentioned in threads #185

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

Southclaws
Copy link
Owner

No description provided.

Copy link

vercel bot commented Sep 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
storyden ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 11, 2024 8:50pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
storyden-homepage ⬜️ Ignored (Inspect) Visit Preview Sep 11, 2024 8:50pm

Copy link

coderabbitai bot commented Sep 11, 2024

Walkthrough

Walkthrough

The changes primarily involve a transition from the content package to the datagraph package across multiple files. This includes modifications to data structures, function signatures, and import statements, particularly focusing on rich text handling and account mentions. New functionalities related to mentions have been introduced, enhancing the data model and allowing for improved management of user interactions. The overall structure and logic of the application remain intact while accommodating these updates.

Changes

Files Change Summary
app/resources/account/*.go Changed Bio field type from content.Rich to datagraph.Content; updated related functions.
app/resources/asset/*.go Altered owner parameter type from account.AccountID to xid.ID in methods.
app/resources/datagraph/*.go Renamed Rich to Content, added new fields and methods for handling references and content.
app/resources/library/*.go Updated content handling to use datagraph.Content instead of content.Rich.
app/services/mention/*.go Introduced new mention handling features and integrated them into the service layer.
internal/ent/*.go Added support for mentions in account management, including new methods and fields for querying.
app/transports/http/bindings/*.go Updated import statements and function calls to utilize datagraph for rich text processing.
app/services/thread/*.go Integrated mention functionality into thread creation and service logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Service
    participant Mentioner
    participant Database

    User->>Service: Create Thread
    Service->>Mentioner: Send Mention
    Mentioner->>Database: Save Mention
    Database-->>Mentioner: Acknowledge
    Mentioner-->>Service: Confirmation
    Service-->>User: Thread Created
Loading

🐰 A hop, a skip, a joyful cheer,
New mentions abound, the changes are here!
From content to datagraph, we leap with glee,
Rich tales now flourish, as bright as can be!
With every update, our paths intertwine,
In this garden of code, all will be fine! 🌼


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.
    • @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 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.

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: 2

Outside diff range and nitpick comments (1)
app/services/mention/mention_job/job.go (1)

33-35: Consider handling the error returned by the ic.mention method.

Currently, if the ic.mention method returns an error, it is only logged using the zap logger. Depending on the nature of the error, it might be beneficial to take some other action, such as retrying the operation or sending a notification.

Consider adding a retry mechanism or error handling based on the type of error returned by the ic.mention method. For example:

if err := ic.mention(ctx, msg.Payload.Source, msg.Payload.Item); err != nil {
    l.Error("failed to record mention", zap.Error(err))
    
    // Check the error type and take appropriate action
    if errors.Is(err, someRetryableError) {
        // Retry the operation with exponential backoff
        // ...
    } else if errors.Is(err, someNonRetryableError) {
        // Send a notification or perform some other action
        // ...
    }
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 44cad02 and ffec502.

Files ignored due to path filters (1)
  • api/openapi.yaml is excluded by !**/*.yaml
Files selected for processing (77)
  • app/resources/account/account.go (2 hunks)
  • app/resources/account/account_writer/account_writer.go (2 hunks)
  • app/resources/account/mapping.go (2 hunks)
  • app/resources/account/notification/event.go (1 hunks)
  • app/resources/account/notification/notification_enum_gen.go (2 hunks)
  • app/resources/asset/asset.go (1 hunks)
  • app/resources/asset/db.go (3 hunks)
  • app/resources/datagraph/content.go (6 hunks)
  • app/resources/datagraph/content_test.go (3 hunks)
  • app/resources/datagraph/indexable.go (2 hunks)
  • app/resources/datagraph/ref.go (1 hunks)
  • app/resources/library/library.go (2 hunks)
  • app/resources/library/mapping.go (2 hunks)
  • app/resources/library/node.go (3 hunks)
  • app/resources/library/node_traversal/db.go (2 hunks)
  • app/resources/mq/message_types.go (1 hunks)
  • app/resources/post/post.go (4 hunks)
  • app/resources/post/post_writer/post_writer.go (2 hunks)
  • app/resources/post/reply/reply.go (2 hunks)
  • app/resources/post/reply/repo.go (2 hunks)
  • app/resources/post/thread/repo.go (2 hunks)
  • app/resources/post/thread/thread.go (2 hunks)
  • app/resources/post/thread_writer/writer.go (2 hunks)
  • app/resources/profile/profile.go (4 hunks)
  • app/resources/seed/post.go (10 hunks)
  • app/services/asset/analyse/pdf.go (2 hunks)
  • app/services/asset/asset_upload/uploader.go (2 hunks)
  • app/services/library/node_mutate/node.go (3 hunks)
  • app/services/link/scrape/postprocess.go (3 hunks)
  • app/services/link/scrape/scraper.go (2 hunks)
  • app/services/mention/mention_job/job.go (1 hunks)
  • app/services/mention/mention_job/mention.go (1 hunks)
  • app/services/mention/mention_job/provider.go (1 hunks)
  • app/services/mention/mentioner/mentioner.go (1 hunks)
  • app/services/reply/service.go (2 hunks)
  • app/services/services.go (2 hunks)
  • app/services/thread/create.go (2 hunks)
  • app/services/thread/service.go (7 hunks)
  • app/transports/http/bindings/nodes.go (3 hunks)
  • app/transports/http/bindings/posts.go (2 hunks)
  • app/transports/http/bindings/replies.go (2 hunks)
  • app/transports/http/bindings/threads.go (3 hunks)
  • app/transports/http/bindings/utils.go (2 hunks)
  • app/transports/http/openapi/server_gen.go (2 hunks)
  • internal/ent/account.go (9 hunks)
  • internal/ent/account/account.go (4 hunks)
  • internal/ent/account/where.go (1 hunks)
  • internal/ent/account_create.go (3 hunks)
  • internal/ent/account_query.go (9 hunks)
  • internal/ent/account_update.go (7 hunks)
  • internal/ent/client.go (12 hunks)
  • internal/ent/ent.go (2 hunks)
  • internal/ent/er.html (3 hunks)
  • internal/ent/hook/hook.go (1 hunks)
  • internal/ent/mentionprofile.go (1 hunks)
  • internal/ent/mentionprofile/mentionprofile.go (1 hunks)
  • internal/ent/mentionprofile/where.go (1 hunks)
  • internal/ent/mentionprofile_create.go (1 hunks)
  • internal/ent/mentionprofile_delete.go (1 hunks)
  • internal/ent/mentionprofile_query.go (1 hunks)
  • internal/ent/mentionprofile_update.go (1 hunks)
  • internal/ent/migrate/schema.go (3 hunks)
  • internal/ent/mutation.go (27 hunks)
  • internal/ent/post.go (7 hunks)
  • internal/ent/post/post.go (4 hunks)
  • internal/ent/post/where.go (1 hunks)
  • internal/ent/post_create.go (3 hunks)
  • internal/ent/post_query.go (9 hunks)
  • internal/ent/post_update.go (7 hunks)
  • internal/ent/predicate/predicate.go (1 hunks)
  • internal/ent/runtime.go (2 hunks)
  • internal/ent/schema/account.go (1 hunks)
  • internal/ent/schema/mention_profile.go (1 hunks)
  • internal/ent/schema/post.go (1 hunks)
  • internal/ent/tx.go (2 hunks)
  • internal/integration/fx.go (2 hunks)
  • web/src/api/openapi-schema/notificationEvent.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • internal/ent/mentionprofile_query.go
  • internal/integration/fx.go
Additional comments not posted (221)
app/resources/account/notification/event.go (1)

8-11: LGTM!

The addition of the new constant eventProfileMention to the eventEnum type is consistent with the existing constants. The constant name is clear, follows the naming convention, and the constant value is unique and descriptive.

The code changes are approved.

app/services/mention/mention_job/provider.go (1)

1-22: LGTM!

The code changes in this new file are approved. The file follows a standard pattern for dependency injection configuration in Go using the fx package. It provides necessary dependencies for the mention job service, including a queue for mq.Mention, a newMentionConsumer function, invocation of runMentionConsumer, and a mentioner.New function. The code is well-structured, modular, and easy to understand.

app/services/mention/mentioner/mentioner.go (2)

13-16: LGTM!

The Mentioner struct is well-defined with appropriate fields for logging and publishing mention messages.


18-20: LGTM!

The New constructor function is well-implemented, taking the required dependencies and returning a new Mentioner instance.

app/services/mention/mention_job/mention.go (3)

3-10: LGTM!

The import statements are correctly importing the required packages from the same module.


12-14: LGTM!

The mentionConsumer struct is correctly defined with the required field.


16-22: LGTM!

The newMentionConsumer function is a constructor for the mentionConsumer struct. It correctly initializes the struct with the provided notifySender argument and returns a pointer to a new mentionConsumer instance.

app/services/mention/mention_job/job.go (1)

14-43: LGTM!

The code changes in the runMentionConsumer function are approved. The function correctly subscribes to the mention queue, processes messages, and records mentions.

web/src/api/openapi-schema/notificationEvent.ts (1)

24-24: LGTM!

The addition of the profile_mention constant to the NotificationEvent object is a valid change that expands the set of notification events. This change aligns with the PR objective of adding mentions in content and notifying members when mentioned in threads.

The code change is approved.

app/resources/mq/message_types.go (1)

57-60: LGTM!

The new Mention struct looks good:

  • The struct name and field names are clear and descriptive.
  • The struct is small and focused, following the Single Responsibility Principle.
  • The struct uses the datagraph.Ref type for both fields, indicating a consistent and appropriate use of types.
  • The struct does not have any methods, which is fine for a simple data structure.

The code changes are approved.

internal/ent/schema/mention_profile.go (1)

1-48: LGTM!

The code changes for the MentionProfile entity schema are well-structured and follow the conventions of the ent framework. The schema includes the necessary fields, edges, and indexes for the entity.

The code is approved.

app/resources/account/account.go (2)

10-10: Verify the transition from the content package to the datagraph package.

The import statement for the content package has been removed and the datagraph package has been imported instead. This change indicates a transition in how rich text content is handled in the application.

Ensure that this transition is consistently applied across the codebase and that all references to the content package for rich text handling have been updated to use the datagraph package instead.

Run the following script to verify the package usage:

Verification successful

Transition from content to datagraph package verified successfully.

The transition from the content package to the datagraph package for handling rich text content has been successfully implemented across the codebase. The content package is no longer in use, and the datagraph package is widely adopted, with the datagraph.Content type replacing content.Rich.

  • No instances of github.com/Southclaws/storyden/app/resources/content or content.Rich were found.
  • The datagraph package and datagraph.Content type are used extensively across multiple files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the transition from the `content` package to the `datagraph` package for rich text handling.

# Test 1: Search for import statements of the `content` package. Expect: No results.
rg --type go $'github.com/Southclaws/storyden/app/resources/content'

# Test 2: Search for usage of the `content.Rich` type. Expect: No results.
rg --type go $'content\.Rich'

# Test 3: Search for import statements of the `datagraph` package. Expect: Results indicating the package is being used.
rg --type go $'github.com/Southclaws/storyden/app/resources/datagraph'

# Test 4: Search for usage of the `datagraph.Content` type. Expect: Results indicating the type is being used.
rg --type go $'datagraph\.Content'  

Length of output: 9193


24-24: Ensure the Bio field type change is handled correctly.

The Bio field in the Account struct has been changed from content.Rich to datagraph.Content. This change aligns with the transition from the content package to the datagraph package for handling rich text content.

Verify that all code that interacts with the Bio field has been updated to handle the new datagraph.Content type correctly. Pay special attention to any serialization, deserialization, or rendering logic that may need to be adapted for the new type.

Run the following script to verify the Bio field usage:

app/resources/asset/asset.go (2)

17-17: LGTM!

The change to the owner parameter type in the Add method signature is approved. It aligns the type with xid.ID, which is used consistently for identifiers in the codebase.


25-25: Looks good!

The change to the owner parameter type in the Remove method signature is approved. It maintains consistency with the Add method and the usage of xid.ID for identifiers.

app/resources/datagraph/ref.go (5)

16-20: LGTM!

The Ref struct is well-defined with appropriate fields and types.


22-24: LGTM!

The GetID method is correctly implemented.


26-28: LGTM!

The GetKind method is correctly implemented.


32-37: LGTM!

The NewRef function is correctly implemented.


39-61: LGTM!

The NewRefFromSDR function is correctly implemented with appropriate URL validation and error handling.

app/resources/account/notification/notification_enum_gen.go (2)

15-18: LGTM!

The variable declarations for event types, including the new EventProfileMention, are correctly implemented and improve code consistency.


64-65: LGTM!

The NewEvent function is correctly updated to handle the new eventProfileMention event type.

app/resources/post/reply/repo.go (2)

10-10: LGTM!

The import statement change from content to datagraph is approved. This change aligns with the shift in the source of the Content type used in the WithContent function.


38-38: LGTM!

The function signature change for WithContent to accept a parameter of type datagraph.Content instead of content.Rich is approved. This change is consistent with the import statement change and the logic within the function remains intact.

app/services/asset/analyse/pdf.go (2)

5-5: LGTM!

The changes to the import statements are approved. The newly imported packages are necessary to support the updated functionality in the analysePDF function.

Also applies to: 10-10, 13-13


35-41: Approved: The changes to the creation of the RichText object look good.

The introduction of the pipe mechanism for processing HTML content is a positive change. It allows for a streaming approach, which may lead to improved memory efficiency and performance compared to the previous method of directly converting HTML to a RichText object.

app/resources/asset/db.go (2)

24-24: Verify the impact of changing the accountID type.

Ensure that changing the accountID parameter type from account.AccountID to xid.ID aligns with the overall design and does not introduce any unintended consequences.

Verify that:

  • The xid.ID type is consistently used for account identifiers across the application.
  • The change does not break any existing functionality or integrations.
  • The new approach improves the handling of account identifiers (e.g., performance, security, consistency).

70-70: Change is consistent with the modification in the Add function.

This change aligns with the previous modification to the accountID parameter type in the Add function. Refer to the comments made for that change.

app/resources/account/mapping.go (2)

11-11: LGTM!

The import statement change from content to datagraph is approved.


21-21: LGTM, but verify the functionality.

The change to use datagraph.NewRichText instead of content.NewRichText is approved.

However, ensure that the functionality of the NewRichText function in the datagraph package matches the previous implementation in the content package. Thoroughly test this change to confirm that it behaves as expected.

app/resources/post/post_writer/post_writer.go (2)

11-11: LGTM!

The import statement change from content to datagraph is approved. It aligns with the update to the WithContent function signature and suggests a shift in the source of the Content type.


31-31: LGTM, but verify the usage of datagraph.Content.

The function signature change from content.Rich to datagraph.Content is approved. It aligns with the import statement update and suggests a shift in the source of the Content type.

However, ensure that the datagraph.Content type is thoroughly tested and provides the necessary functionality for the WithContent function. Verify that all usages of WithContent have been updated to pass the correct type.

Run the following script to verify the usage of datagraph.Content:

Verification successful

Change to datagraph.Content is correctly implemented.

The function WithContent has been updated to use datagraph.Content consistently across the codebase. The methods HTML() and Short() used within the function body confirm compatibility with the previous type. No issues found with this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `WithContent` pass the correct type.

# Test: Search for the function usage. Expect: Only occurrences with `datagraph.Content` argument.
rg --type go -A 5 $'WithContent'

Length of output: 8941

app/resources/datagraph/indexable.go (4)

10-10: LGTM!

The addition of the ErrInvalidReferenceScheme error variable using the fault package is a good practice for standardized error handling. The error message clearly conveys the purpose of the error.


17-17: Verify the impact of changing the return type of GetContent.

The return type of the GetContent method in the WithContent interface has been changed from content.Rich to Content. This suggests a shift in the underlying data structure or type being used for content representation.

Please ensure that this change is thoroughly tested and that all code relying on the GetContent method has been updated to handle the new return type correctly.


Line range hint 1-1: Verify the impact of removing the Ref type and associated functionality.

The removal of the Ref type, its associated methods GetID and GetKind, and the NewRef function indicates a significant refactor or removal of functionality related to references in the context of semdex operations.

Please ensure that this removal does not break any existing functionality and that all code relying on the removed Ref type and associated methods has been updated accordingly.


Line range hint 1-1: LGTM!

The rest of the file looks good and does not require any further comments.

app/resources/library/node.go (2)

41-41: LGTM!

The change to the Content field type aligns with the transition from the content package to the datagraph package. It is consistent with the import statements and the overall refactoring.


70-70: LGTM!

The change to the GetContent() method return type is necessary to align with the updated Content field type. It maintains the consistency and integrity of the code.

app/resources/library/mapping.go (2)

9-10: LGTM!

The changes to the import statements, replacing the content package with the datagraph package, are approved. This refactoring effort is consistent with the update to the NewRichText function call later in the file.


51-51: LGTM!

The change to the NewRichText function call, replacing content.NewRichText with datagraph.NewRichText, is approved. This update is consistent with the refactoring effort to move the rich text processing functionality from the content package to the datagraph package.

app/resources/datagraph/content_test.go (4)

6-7: LGTM!

The new import statements for utils and xid packages are approved.


12-17: LGTM!

The changes in the check function to use the Content type instead of the Rich type are approved.


22-23: LGTM!

The changes in the test cases to use the Content type and update the field names are approved.

Also applies to: 39-41


51-61: LGTM!

The new test case with_uris is approved. It enhances the test coverage by validating the handling of URIs and the RefList structure.

internal/ent/predicate/predicate.go (1)

42-43: LGTM!

The addition of the MentionProfile predicate function type is consistent with the existing predicate function types in the file. It follows the same naming convention and function signature, accepting a pointer to sql.Selector as an argument.

The code segment is well-structured and adheres to the coding style of the file.

app/transports/http/bindings/replies.go (2)

11-11: LGTM!

The import statement change from content to datagraph is approved. It aligns with the PR objective of transitioning to the datagraph package.


48-48: LGTM!

The change in the ReplyCreate function to use datagraph.NewRichText instead of content.NewRichText is approved. It aligns with the import statement change and the PR objective of transitioning to the datagraph package. The overall functionality of the ReplyCreate function remains intact.

app/services/thread/create.go (2)

14-14: LGTM!

The import statement for the datagraph package is necessary and looks good.


76-76: LGTM!

The new line of code that sends mentions related to the thread being created looks good. It enhances the functionality by integrating a mechanism to send mentions, potentially improving the interaction with referenced content.

The datagraph.NewRef(thr) call creates a new reference from the thread, which is then used to send the mentions. The thr.Content.References() call retrieves the references from the thread content to be sent as mentions.

The placement of this code, after the content URLs are hydrated and before returning the thread object, seems appropriate.

app/resources/post/thread_writer/writer.go (2)

10-10: LGTM!

The import statement change from content to datagraph is approved. It aligns with the overall transition to the datagraph package for content representation.


48-48: LGTM, but verify the function usage.

The function signature change of WithContent to accept datagraph.Content instead of content.Rich is approved. It aligns with the overall transition to the datagraph package for content representation.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all function calls to WithContent have been updated to pass the correct datagraph.Content type.

Run the following script to verify the function usage:

Verification successful

Function usage verified.

The WithContent function is correctly used with the datagraph.Content type across the codebase. All instances of its usage align with the updated function signature.

  • Files with verified usage:
    • app/services/reply/service.go
    • app/services/thread/service.go
    • app/resources/seed/post.go
    • app/services/library/node_mutate/node.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `WithContent` pass the correct type.

# Test: Search for the function usage. Expect: Only occurrences of `WithContent(datagraph.Content{...})`.  
rg --type go -A 5 $'WithContent'

Length of output: 8941

app/services/link/scrape/scraper.go (1)

10-10: Acknowledge the package change from content to datagraph.

The import statement for the content package has been replaced with the datagraph package, and the Content field in the WebContent struct has been updated accordingly.

This change suggests a shift in how content is handled and may impact the web scraper's functionality. Ensure that the new datagraph package provides the necessary methods and properties for the scraper to operate correctly.

Also applies to: 25-25

internal/ent/schema/account.go (1)

59-60: LGTM!

The new edge relationship from Account to MentionProfile with cascading delete behavior is a good addition. It allows associating accounts with their mention profiles and ensures data integrity by deleting the associated mention profiles when an account is deleted.

This change aligns well with the PR objective of adding mentions functionality.

app/services/asset/asset_upload/uploader.go (1)

62-62: LGTM! The change to wrap accountID with xid.ID() is a good improvement.

Using xid provides the following benefits:

  • It generates globally unique identifiers that are suitable for use as database primary keys or unique references.
  • The identifiers are URL-safe and can be included in URLs or HTML forms without encoding.
  • xid generates more compact identifiers compared to UUID, which can save storage space when storing many IDs.

So this change helps ensure that account identifiers are globally unique and can be safely used across different contexts.

app/resources/profile/profile.go (1)

12-12: LGTM!

The changes consistently transition from the content package to the datagraph package for handling rich text content. This is reflected in:

  • The Bio field type in the Public struct.
  • The GetContent() method signature.
  • The ProfileFromModel function's usage of datagraph.NewRichText.

The modifications align with what seems to be a broader refactor or enhancement of the content management system. The code changes are coherent and maintain the overall structure and logic of the profile-related functionality.

Also applies to: 25-25, 35-42, 52-52

app/services/reply/service.go (2)

13-13: LGTM!

The new import statement for the datagraph package is necessary to use the datagraph.Content type in the Partial struct.


38-38: LGTM!

The changes to the Partial struct and Opts() method are consistent and correctly reflect the shift from using the content package to the datagraph package for content representation.

Also applies to: 44-44

app/services/services.go (2)

21-21: LGTM!

The new import statement for the mention_job package is approved. It indicates that the functionality related to handling mention jobs or tasks is now being used in this file.


54-54: LGTM!

The addition of mention_job.Build() in the Build function is approved. It indicates that the mention job functionality is now being initialized and integrated into the application's service layer, enhancing the service's capabilities to handle and process user mentions.

internal/ent/schema/post.go (1)

84-85: LGTM!

The new mentions edge correctly establishes the relationship between Post and MentionProfile entities. The cascading delete annotation ensures data integrity.

app/resources/library/library.go (2)

10-10: LGTM!

The import statement change from content to datagraph package is approved.


Line range hint 84-88: LGTM, but verify the function usage.

The changes to the WithContent function are approved.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all function calls to WithContent have been updated to pass the correct parameter type.

Run the following script to verify the function usage:

Verification successful

Function usage verified: WithContent is correctly used with datagraph.Content.

The WithContent function is consistently called with the correct parameter type across the codebase, confirming that the changes have been properly integrated. No further issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `WithContent` pass the correct parameter type.

# Test: Search for the function usage. Expect: Only occurrences of `WithContent` with `datagraph.Content` argument.
rg --type go -A 5 $'WithContent'

Length of output: 8941

internal/ent/mentionprofile_delete.go (1)

1-88: LGTM!

The generated code for deleting a MentionProfile entity looks good. It follows the standard structure and best practices for ent framework's generated code.

The code provides the necessary functionality for configuring and executing deletion queries for a single entity or multiple entities based on predicates.

No issues or areas for improvement were identified.

app/resources/post/post.go (3)

12-12: LGTM!

The import changes are approved. They align with the transition from the content package to the datagraph package for content handling.


45-52: LGTM!

The GetContent method and Map function changes are approved. They align with the transition from the content package to the datagraph package for content handling.

Also applies to: 73-73


32-32: LGTM, but verify the field usage.

The Content field type change from content.Rich to datagraph.Content is approved.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all usages of the Content field have been updated to match the new type.

Run the following script to verify the field usage:

Verification successful

Field Type Change Verified Successfully

The Content field type change from content.Rich to datagraph.Content has been verified across the codebase. All usages are consistent with the new type, and no issues were found.

  • The change is reflected in various files, including internal/ent/node_create.go, internal/ent/post_update.go, app/resources/post/post.go, and others.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of the `Content` field match the new type.

# Test: Search for the field usage. Expect: Only occurrences of the new type.
rg --type go -A 5 $'\\.(Content)'

Length of output: 51304

app/services/link/scrape/postprocess.go (3)

15-15: LGTM!

The import statement changes are approved. The shift from the readability package to the datagraph package aligns with the overall refactoring of the content processing logic.


30-35: LGTM!

The changes in the postprocess function are approved. The refactoring of the getArticleContent function call and the derivation of the text variable from the rc.Short() method align with the overall simplification of the content processing logic.


66-72: LGTM!

The changes in the getArticleContent function are approved. The shift to the datagraph package and the utilization of datagraph.NewRichTextFromReader align with the overall refactoring of the content processing logic. The simplification of the function's output by removing the text content return value further streamlines the code.

app/resources/post/reply/reply.go (2)

9-9: LGTM!

The import statement changes are approved. The removal of the content package import and the addition of the datagraph package import are consistent with the transition from the content package to the datagraph package.

Also applies to: 15-15


73-73: LGTM!

The changes in the FromModel function are approved. The replacement of the content.NewRichText function call with datagraph.NewRichText is consistent with the transition from the content package to the datagraph package.

app/transports/http/bindings/posts.go (2)

12-12: LGTM!

The import statement change is approved. It is consistent with the alteration mentioned in the "Alterations to the declarations of exported or public entities" section, which indicates that the NewRichText function is now being provided by the datagraph package instead of the content package.


43-43: LGTM!

The NewRichText function call change is approved. It is consistent with the import statement change and the alteration mentioned in the "Alterations to the declarations of exported or public entities" section, which indicates that the NewRichText function is now being provided by the datagraph package instead of the content package.

app/resources/account/account_writer/account_writer.go (2)

16-16: LGTM!

The import statement changes are approved. The datagraph package is now being used instead of the content package.


50-52: LGTM, but verify the function usage.

The function signature changes are approved.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all function calls to WithBio have been updated to pass the correct parameter type.

Run the following script to verify the function usage:

Verification successful

Function usage is correct.

The WithBio function is used correctly in app/resources/seed/account.go, as the Bio field is of type datagraph.Content, matching the updated function signature.

  • app/resources/seed/account.go: account_writer.WithBio(v.Bio)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `WithBio` pass the correct parameter type.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'WithBio'

Length of output: 742


Script:

#!/bin/bash
# Description: Determine the type of `v.Bio` in `app/resources/seed/account.go`.

# Search for the definition or declaration of `v` to find its type.
rg --type go -A 5 'v\s*:=' app/resources/seed/account.go

Length of output: 196


Script:

#!/bin/bash
# Description: Determine the type of elements in `Accounts` to verify the type of `v.Bio`.

# Search for the declaration or definition of `Accounts` in the codebase.
rg --type go 'Accounts\s*='

Length of output: 811


Script:

#!/bin/bash
# Description: Check the type of the `Bio` field in the `account.Account` struct.

# Search for the definition of the `account.Account` struct.
rg --type go 'type Account struct' -A 10

Length of output: 2752

app/resources/post/thread/thread.go (1)

86-86: LGTM, but verify the NewRichText function usage.

The change to use the datagraph package for the NewRichText function is approved.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all calls to NewRichText have been updated to use the datagraph package.

Run the following script to verify the NewRichText function usage:

Verification successful

Verification Successful: NewRichText function usage is consistent.

The NewRichText function is correctly used with the datagraph package across the codebase, confirming the change is properly implemented. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `NewRichText` use the `datagraph` package.

# Test: Search for the function usage. Expect: Only occurrences using the `datagraph` package.
rg --type go -A 5 $'NewRichText'

Length of output: 15706

app/services/thread/service.go (4)

16-16: LGTM!

The import statement changes are approved. The content package has been correctly replaced with the datagraph package, and the mentioner package has been added to support the new mentioning functionality.

Also applies to: 25-25


61-61: LGTM!

The Partial struct change is approved. The Content field type has been correctly updated to opt.Optional[datagraph.Content] to reflect the package replacement.


71-71: LGTM!

The Opts() method change is approved. The callback parameter type has been correctly updated to datagraph.Content to reflect the package replacement.


92-92: LGTM!

The service struct and New function changes are approved. The new mentioner field has been correctly added to the service struct, and the New function has been updated to accept and initialize the mentioner parameter.

Also applies to: 104-104, 114-114

app/resources/post/thread/repo.go (2)

12-12: LGTM!

The import statement change from content to datagraph is approved. This change is consistent with the provided summary.


74-74: LGTM, but verify the impact on downstream logic.

The function signature change for WithContent to accept a parameter of type datagraph.Content instead of content.Rich is approved. This change is consistent with the import statement change and the provided summary.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and doesn't break any downstream logic that relies on the properties or methods of the Content type.

Run the following script to verify the impact on downstream logic:

Verification successful

Function signature change for WithContent is consistent and verified.

The function signature change for WithContent to accept a parameter of type datagraph.Content is consistently applied across the codebase. The usage of datagraph.Content is widespread and integrated, indicating that the transition from content.Rich is complete and does not negatively impact downstream logic. No issues were found in the current implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `WithContent` and `datagraph.Content` in the codebase.

# Test 1: Search for the usage of `WithContent`. Expect: Only occurrences with the new signature.
rg --type go -A 5 $'WithContent'

# Test 2: Search for the usage of `datagraph.Content`. Expect: Relevant occurrences in the codebase.
rg --type go -A 5 $'datagraph\.Content'

Length of output: 18250

internal/ent/mentionprofile/mentionprofile.go (3)

1-3: LGTM!

The license header and package declaration are correctly defined.


5-11: Looks good!

The import statements are correctly defined and only include the necessary packages.


13-122: Schema definition looks good!

The MentionProfile schema is well-defined with appropriate fields, edges, and database mapping. It follows the ent framework conventions and is structured correctly.

app/resources/datagraph/content.go (6)

1-20: LGTM!

The added import statements are necessary for the new functionalities introduced in the file.


22-40: LGTM!

The introduction of the RefScheme constant and the redefinition of the policy variable enhance the data structure and sanitization capabilities to accommodate references to resources.


Line range hint 50-86: LGTM!

The renaming of the Rich type to Content, the addition of the sdrs field, and the updates to the associated methods improve the structure and functionality of the code, allowing for better handling of content and references.


95-131: LGTM!

The refactoring of the NewRichText function to call the new NewRichTextFromReader function improves code organization and clarity by separating the input processing logic into a dedicated function.


Line range hint 134-187: LGTM!

The introduction of the extractReferences function improves code organization and clarity by separating the reference extraction logic into a dedicated function.


Line range hint 189-225: LGTM!

The addition of the getSummary function enhances the functionality of the Content type by providing a summary generation capability.

app/transports/http/bindings/threads.go (3)

59-59: LGTM!

The change from content.NewRichText to datagraph.NewRichText in the ThreadCreate method is approved.


107-107: LGTM!

The change from content.NewRichText to datagraph.NewRichText in the ThreadUpdate method is approved.


16-17: LGTM, but verify the usage of the datagraph package.

The import statement change from content to datagraph is approved.

However, ensure that the datagraph package provides the necessary functionality for rich text creation and that this change is consistently applied across the codebase.

Run the following script to verify the usage of the datagraph package:

Verification successful

Verification Successful: Consistent Usage of datagraph Package

The datagraph.NewRichText function is used consistently across the codebase, confirming that the transition from the content package to the datagraph package for rich text creation has been implemented correctly.

  • Files with consistent usage include:
    • app/resources/profile/profile.go
    • app/resources/post/post.go
    • app/resources/post/thread/thread.go
    • app/resources/seed/post.go
    • app/resources/post/reply/reply.go
    • app/resources/library/mapping.go
    • app/resources/library/node_traversal/db.go
    • app/services/link/scrape/postprocess.go
    • app/resources/account/mapping.go
    • app/transports/http/bindings/threads.go
    • app/transports/http/bindings/replies.go
    • app/transports/http/bindings/posts.go
    • app/transports/http/bindings/nodes.go
    • app/services/asset/analyse/pdf.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `datagraph` package for rich text creation.

# Test: Search for the usage of `datagraph.NewRichText`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'datagraph.NewRichText'

Length of output: 13350

internal/ent/mentionprofile.go (8)

1-1: Do not edit this file.

This file is generated by ent. Any manual changes will be overwritten when the code is regenerated.


19-33: LGTM!

The MentionProfile struct is correctly defined following the ent conventions.


36-44: LGTM!

The MentionProfileEdges struct is correctly defined following the ent conventions.


48-55: LGTM!

The AccountOrErr method is correctly implemented following the ent conventions.


59-66: LGTM!

The PostOrErr method is correctly implemented following the ent conventions.


69-82: LGTM!

The scanValues method is correctly implemented following the ent conventions.


86-121: LGTM!

The assignValues method is correctly implemented following the ent conventions.


125-127: LGTM!

The Value method is correctly implemented following the ent conventions.

internal/ent/er.html (3)

103-108: LGTM!

The new MentionProfile entity with fields id, created_at, account_id, and post_id is well-defined for representing a mention of an account in a post.


184-184: LGTM!

The one-to-many relationship Account |o--o{ MentionProfile : "mentions/account" correctly models that an account can have multiple mentions.


211-211: LGTM!

The one-to-many relationship Post |o--o{ MentionProfile : "mentions/Post" correctly models that a post can contain multiple mentions.

app/transports/http/bindings/utils.go (2)

11-11: Package import updated.

The content package import has been replaced with the datagraph package import. This change suggests a refactoring to use the datagraph package for content-related functionality.


83-83: Function signature updated to reflect the package change.

The serialiseContentHTML function signature has been updated to accept a parameter of type datagraph.Content instead of content.Rich. This change aligns with the package import update from content to datagraph.

app/services/library/node_mutate/node.go (2)

19-19: LGTM!

The import statement change from content to datagraph is approved.


46-46: LGTM!

The changes in the Partial struct and Opts() method to use the datagraph.Content type are approved. They are consistent with the import statement change.

Also applies to: 63-63

app/resources/library/node_traversal/db.go (2)

14-14: LGTM!

The import statement for the datagraph package has been added correctly to support the usage of datagraph.NewRichText in the fromRow function.


150-150: Verify the impact of the datagraph transition.

The content.NewRichText function call has been replaced with datagraph.NewRichText, suggesting a shift in the source of the rich text processing functionality.

This change may have implications for how the OwnerBio data is represented or processed downstream. Ensure that this transition is thoroughly tested and validated.

To verify the impact of the datagraph transition, consider running the following checks:

  1. Confirm that the datagraph.NewRichText function has the same behavior and output as the previous content.NewRichText function.

  2. Identify all the places where the OwnerBio data is used or displayed and ensure that the transition to datagraph does not introduce any regressions or unexpected changes.

  3. Review the relevant documentation and update it to reflect the transition from content to datagraph for rich text processing.

  4. If applicable, update any relevant tests to cover the usage of datagraph.NewRichText and ensure that the test coverage remains adequate after this change.

internal/ent/tx.go (2)

39-40: LGTM!

The addition of the MentionProfile field to the Tx struct is approved. This change expands the capabilities of the Tx struct to handle MentionProfile-related operations.


197-197: LGTM!

The initialization of tx.MentionProfile in the init method of the Tx struct is approved. This change ensures that the MentionProfile client is properly instantiated alongside the other clients.

app/resources/seed/post.go (4)

12-12: LGTM!

The change from the content package to the datagraph package for handling rich text content is approved.


33-33: LGTM!

The change to use datagraph.NewRichText for initializing the Content field is approved.


73-73: LGTM!

All the changes to use datagraph.NewRichText for initializing the Content field are approved.

Also applies to: 81-81, 89-89, 97-97, 105-105, 116-116, 124-124, 132-132, 143-143, 153-153, 180-180, 188-188, 200-200, 210-210, 218-218, 226-226, 234-234


257-257: Verify the impact of the author ID change.

The change to use xid.ID(t.Author.ID) instead of t.Author.ID for the author ID argument in the ar.Add function call suggests a potential update in how author identifiers are managed.

Please ensure that this change is thoroughly tested and does not introduce any inconsistencies or breaking changes in the system.

internal/ent/mentionprofile/where.go (1)

1-313: This is a generated file and should not be modified directly.

The code in this file is generated by the ent framework based on the schema definition. It provides a set of predicate functions for filtering MentionProfile entities based on various fields such as ID, CreatedAt, AccountID, and PostID.

The generated predicates follow a consistent pattern and cover common comparison operations like equality, inequality, less than, greater than, etc. The predicates can be combined using logical operators like And, Or, and Not to create complex filtering conditions.

It's important to note that this file should not be modified directly. Any changes to the predicates should be made by updating the schema definition and regenerating the code.

app/transports/http/bindings/nodes.go (2)

18-19: LGTM!

The import statement changes are approved. Replacing the content package import with the datagraph package import aligns with the objective of transitioning to the datagraph package for handling rich text content.


69-69: LGTM!

The NewRichText function usage changes in the NodeCreate and NodeUpdate methods are approved. Using the datagraph package instead of the content package for the NewRichText function aligns with the import statement changes and the objective of transitioning to the datagraph package for handling rich text content.

Also applies to: 206-206

internal/ent/hook/hook.go (1)

144-154: LGTM!

The new MentionProfileFunc adapter type and its Mutate method follow the established pattern in this file. They enhance the flexibility of mutation handling for the MentionProfile entity by allowing ordinary functions to be used as mutators.

The code changes are approved.

internal/ent/account.go (4)

65-66: LGTM!

The addition of the Mentions field to the AccountEdges struct and the corresponding increase in the size of the loadedTypes array are consistent and valid.

Also applies to: 81-81


156-163: LGTM!

The MentionsOrErr method implementation is consistent with the other similar methods in the AccountEdges struct. It correctly checks the loadedTypes array at index 8 to determine if the Mentions field has been loaded.


367-370: LGTM!

The QueryMentions method implementation is consistent with the other similar query methods in the Account struct. It correctly uses the NewAccountClient to create a query for the "mentions" edge.


65-66: Verify the usage of the new Mentions field and QueryMentions method.

Please ensure that the new Mentions field in the AccountEdges struct and the QueryMentions method in the Account struct are being used correctly in the rest of the codebase.

Run the following script to verify the usage:

Also applies to: 156-163, 367-370

Verification successful

The Mentions field and QueryMentions method are used correctly.

The Mentions field in the AccountEdges struct and the QueryMentions method in the Account struct are properly integrated and used within the codebase. They are part of the entity and query structures for both Account and Post, indicating correct usage. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `Mentions` field and `QueryMentions` method.

# Test 1: Search for the usage of the `Mentions` field. Expect: At least one occurrence.
rg --type go -A 5 $'Mentions \[\]\*MentionProfile'

# Test 2: Search for the usage of the `QueryMentions` method. Expect: At least one occurrence.
rg --type go -A 5 $'QueryMentions\(\)'

Length of output: 2571

internal/ent/mentionprofile_update.go (5)

1-1: Generated file, do not edit.

This file is auto-generated by ent. Any manual changes will be overwritten on subsequent code generation.


20-131: MentionProfileUpdate struct and methods look good.

The update builder struct and its methods for configuring the update operation follow the standard ent conventions and are implemented correctly.


133-214: sqlSave method is implemented correctly.

The method generates and executes the SQL UPDATE statement following the standard ent patterns. It properly handles updating or clearing the Account and Post edges.


216-335: MentionProfileUpdateOne struct and methods are valid.

The update builder struct for a single entity and its methods are implemented correctly, following the ent conventions. The additional Select and Exec methods provide more control over the update operation.


337-438: sqlSave method of MentionProfileUpdateOne is correct.

The method follows the same patterns as the sqlSave method of MentionProfileUpdate, with additional checks and functionality for updating a single entity. It is implemented correctly.

internal/ent/ent.go (2)

26-26: LGTM!

The new import statement for the mentionprofile package is necessary to support the new functionality related to mention profiles.


105-105: LGTM!

The update to the checkColumn function to include a new entry for mentionprofile.Table is necessary to support the new functionality related to mention profiles.

internal/ent/post.go (4)

82-83: LGTM!

The addition of the Mentions field to the PostEdges struct is approved. It enables the representation of mentions within a post and is consistent with the existing fields in the struct.


186-193: LGTM!

The addition of the MentionsOrErr method to the PostEdges struct is approved. It provides a consistent way to retrieve the mentions while handling the case when they are not loaded, following the same pattern as the existing OrErr methods for other edges.


198-198: LGTM!

The adjustments to the indices used to check the loading status of the Assets, Collections, Link, and ContentLinks edges are approved. These changes correctly account for the expansion of the loadedTypes array due to the addition of the Mentions field.

Also applies to: 207-207, 218-218, 227-227


429-432: LGTM!

The addition of the QueryMentions method to the Post struct is approved. It provides a consistent way to query the mentions edge of a post entity, following the same pattern as the existing query methods for other edges.

internal/ent/post/post.go (3)

67-68: LGTM!

The added constants for the mentions edge, table, inverse table, and column are well-defined and follow the existing naming conventions. They provide a clear structure for handling mentions in the database schema.

Also applies to: 128-134


434-446: LGTM!

The added order functions ByMentionsCount and ByMentions are implemented correctly and follow the same pattern as other order functions in the file. They provide useful functionality for ordering results based on mentions count or specific mention terms.


559-565: LGTM!

The added helper function newMentionsStep is implemented correctly and follows the same pattern as other step functions in the file. It properly establishes the relationship between the main table and the mentions table in the graph structure.

internal/ent/mentionprofile_create.go (2)

21-257: Code looks good!

The MentionProfileCreate struct and its methods are generated correctly based on the MentionProfile schema. The field and edge setting methods, Save, Exec, and OnConflict configuration are implemented as expected by the ent framework.


413-642: Bulk creation code is properly generated!

The MentionProfileCreateBulk struct and its methods are generated correctly for handling bulk creation of MentionProfile entities. The Save method properly iterates over the builders, invokes mutation hooks, and creates entities in bulk. The OnConflict configuration for bulk creation is also generated as expected by the ent framework.

internal/ent/account/account.go (5)

52-53: LGTM!

The new constant EdgeMentions is correctly defined and follows the naming convention of other edge constants.


124-130: LGTM!

The new constants MentionsTable, MentionsInverseTable, and MentionsColumn are correctly defined and follow the naming convention of other table and column constants.


378-383: LGTM!

The new ByMentionsCount function is correctly implemented and follows the pattern of other ByXCount functions.


385-390: LGTM!

The new ByMentions function is correctly implemented and follows the pattern of other ByX functions.


531-537: LGTM!

The new newMentionsStep function is correctly implemented and follows the pattern of other newXStep functions.

internal/ent/account/where.go (2)

644-652: LGTM!

The HasMentions function correctly applies the HasEdge predicate on the "mentions" edge, following the established pattern in this file.


655-664: LGTM!

The HasMentionsWith function correctly extends the functionality of HasMentions by allowing additional conditions, following the established pattern in this file. It enhances the flexibility of the edge querying.

internal/ent/migrate/schema.go (3)

336-341: LGTM!

The MentionProfilesColumns declaration looks good. It correctly defines the columns for the "mention_profiles" table with appropriate types and sizes.


343-368: LGTM!

The MentionProfilesTable declaration is well-structured and follows the schema conventions. The foreign key constraints ensure referential integrity with the "accounts" and "posts" tables, and the "ON DELETE CASCADE" behavior maintains data consistency. The unique index enforces uniqueness of the combination of "account_id" and "post_id".


847-848: LGTM!

The initialization of foreign key references for MentionProfilesTable is correct. It properly sets the RefTable for each foreign key to the corresponding table, ensuring that the foreign key constraints are properly linked to the referenced tables.

internal/ent/runtime.go (1)

19-19: LGTM!

The code changes related to the MentionProfile schema are well-structured and follow best practices:

  • The mentionprofileMixin is correctly derived from the MentionProfile schema to define fields and default values.
  • Default values for created_at and id fields are properly set using descriptors obtained from the mixin fields.
  • The validator function for the id field aggregates multiple validation functions to ensure data integrity.

These enhancements establish default behaviors and validation mechanisms, improving the overall functionality and consistency of the MentionProfile schema.

Also applies to: 516-546

internal/ent/post/where.go (2)

1112-1120: LGTM!

The code changes are approved.


1123-1132: LGTM!

The code changes are approved.

internal/ent/account_create.go (2)

270-273: LGTM!

The code changes are approved. The AddMentionIDs function follows the established pattern for adding edge entities to the Account.


276-282: LGTM!

The code changes are approved. The AddMentions function correctly converts the MentionProfile instances to IDs and delegates the addition to AddMentionIDs.

internal/ent/post_query.go (3)

286-304: LGTM!

The QueryMentions function is implemented correctly. It properly chains the current query on the "mentions" edge, prepares the query, and handles errors gracefully.


708-715: LGTM!

The WithMentions function is implemented correctly. It allows eager-loading of nodes connected to the "mentions" edge and properly configures the query builder using the provided options.


1282-1310: LGTM!

The loadMentions function is implemented correctly. It properly loads mentions from the database, establishes the relationships between posts and their associated mentions, and assigns the loaded mentions to the corresponding posts.

internal/ent/post_create.go (4)

21-21: LGTM!

The new import statement for the mentionprofile package is approved. It will enable interacting with mention profiles as part of the new mention functionality.


357-361: LGTM!

The AddMentionIDs method is approved. It provides a clean way to add mentions to a post by their IDs during the post creation process.


363-370: LGTM!

The AddMentions method is approved. It offers a convenient way to add mentions using MentionProfile entities directly. By extracting the IDs and calling AddMentionIDs internally, it maintains a consistent approach to associating mentions with a post.


743-758: LGTM!

The changes in the createSpec method are approved. The added code correctly handles the creation of the "mentions" edge when MentionIDs are present in the mutation. This ensures that the relationship between a post and its associated mentions is properly established in the database during the post creation process.

internal/ent/account_query.go (6)

21-21: LGTM!

The import statement for the mentionprofile package is correctly added to support the new mentions edge in the AccountQuery struct.


47-47: LGTM!

The withMentions field is correctly added to the AccountQuery struct to support eager loading of mentions when building queries.


267-287: LGTM!

The QueryMentions method is correctly implemented to facilitate querying mentions linked to an account. It constructs a query using the MentionProfileClient, setting up the necessary SQL graph steps to retrieve the relevant data.


722-731: LGTM!

The WithMentions method is correctly implemented to enable eager loading of mentions when building queries. It allows optional configurations to be passed to customize the query for mentions, similar to existing methods for other edges.


Line range hint 877-886: LGTM!

The update to the loadedTypes array in the sqlAll method is correctly made to account for mentions in the internal logic of the method.


1273-1302: LGTM!

The loadMentions method is correctly implemented to handle the loading of mention data into the account nodes. It ensures that the relationships are correctly established and populated.

internal/ent/post_update.go (11)

400-403: LGTM!

The code changes are approved.


406-412: LGTM!

The code changes are approved.


599-602: LGTM!

The code changes are approved.


605-608: LGTM!

The code changes are approved.


611-617: LGTM!

The code changes are approved.


1138-1182: LGTM!

The code changes to the sqlSave method correctly handle the new "mentions" edges and follow the established patterns for managing edges in the mutation.


1727-1730: LGTM!

The code changes are approved.


1733-1739: LGTM!

The code changes are approved.


1926-1929: LGTM!

The code changes are approved.


1932-1944: LGTM!

The code changes are approved.


2495-2539: LGTM!

The code changes to the sqlSave method for PostUpdateOne correctly handle the new "mentions" edges and follow the established patterns for managing edges in the mutation.

internal/ent/account_update.go (12)

22-22: Imports look good!

The addition of the "mentionprofile" package aligns with the new functionality related to mentions.


287-290: AddMentionIDs method looks good!

The method follows the established pattern for adding edges by IDs.


293-299: AddMentions method looks good!

The method provides a convenient way to add mentions by accepting MentionProfile objects directly.


565-568: ClearMentions method looks good!

The method allows clearing all mentions in a single operation.


571-574: RemoveMentionIDs method looks good!

The method follows the established pattern for removing edges by IDs.


577-583: RemoveMentions method looks good!

The method provides a convenient way to remove mentions by accepting MentionProfile objects directly.


1181-1225: Updates to sqlSave method look good!

The new logic for handling mentions follows the established pattern for managing edge operations during the SQL save operation.


1757-1760: AddMentionIDs method for AccountUpdateOne looks good!

The method follows the same pattern as the corresponding method in AccountUpdate.


1763-1769: AddMentions method for AccountUpdateOne looks good!

The method provides a convenient way to add mentions by accepting MentionProfile objects directly, similar to the corresponding method in AccountUpdate.


2035-2038: ClearMentions method for AccountUpdateOne looks good!

The method allows clearing all mentions in a single operation, similar to the corresponding method in AccountUpdate.


2041-2044: RemoveMentionIDs method for AccountUpdateOne looks good!

The method follows the same pattern as the corresponding method in AccountUpdate.


2047-2053: RemoveMentions method for AccountUpdateOne looks good!

The method provides a convenient way to remove mentions by accepting MentionProfile objects directly, similar to the corresponding method in AccountUpdate.

internal/ent/client.go (4)

2430-2438: LGTM!

The declaration of the MentionProfileClient struct and the NewMentionProfileClient function look good.


2440-2593: LGTM!

The implementation of CRUD operations, bulk creation methods, hooks, and interceptors for MentionProfileClient looks good and follows the established patterns.


597-611: LGTM!

The addition of QueryMentions methods to AccountClient and PostClient looks good. The implementation follows the established patterns and correctly uses sqlgraph to construct the necessary queries.

Also applies to: 3289-3303


69-70: LGTM!

The integration of MentionProfileClient with other clients and schemas looks good. The client is properly added to the necessary structs and methods, ensuring it can be used alongside other clients. The initialization and inclusion in transactional operations are handled correctly.

Also applies to: 107-107, 218-218, 256-256, 340-341, 2594-2594, 4026-4027, 4031-4032

internal/ent/mutation.go (23)

25-25: LGTM!

The new import statement is necessary to support the MentionProfile entity.


58-58: LGTM!

The new constant is necessary to represent the MentionProfile entity type.


109-111: LGTM!

The new fields are necessary to manage the "mentions" edge in the AccountMutation.


1063-1115: LGTM!

The new methods are necessary to manage the "mentions" edge in the AccountMutation.


1737-1737: LGTM!

The increased capacity of the edges slice is necessary to accommodate the new "mentions" edge.


1762-1764: LGTM!

The change is necessary to include the "mentions" edge in the list of added edges.


1838-1843: LGTM!

The change is necessary to return the IDs of the added "mentions" edge.


1886-1886: LGTM!

The increased capacity of the edges slice is necessary to accommodate the new "mentions" edge.


1911-1913: LGTM!

The change is necessary to include the "mentions" edge in the list of removed edges.


1987-1992: LGTM!

The change is necessary to return the IDs of the removed "mentions" edge.


2035-2035: LGTM!

The increased capacity of the edges slice is necessary to accommodate the new "mentions" edge.


2060-2062: LGTM!

The change is necessary to include the "mentions" edge in the list of cleared edges.


2104-2105: LGTM!

The change is necessary to check if the "mentions" edge is cleared.


2158-2160: LGTM!

The change is necessary to reset the "mentions" edge.


9708-10246: LGTM!

The MentionProfileMutation struct and its related methods are necessary to support mutations for the new MentionProfile entity.


12836-12838: LGTM!

The new fields are necessary to manage the "mentions" edge in the PostMutation.


14019-14071: LGTM!

The new methods are necessary to manage the "mentions" edge in the PostMutation.


14684-14684: LGTM!

The increased capacity of the edges slice is necessary to accommodate the new "mentions" edge.


14712-14714: LGTM!

The change is necessary to include the "mentions" edge in the list of added edges.


14780-14785: LGTM!

The change is necessary to return the IDs of the added "mentions" edge.


14814-14814: LGTM!

The increased capacity of the edges slice is necessary to accommodate the new "mentions" edge.


14830-14832: LGTM!

The change is necessary to include the "mentions" edge in the list of removed edges.


14879-14884: LGTM!

The change is necessary to return the IDs of the removed "mentions" edge.

app/transports/http/openapi/server_gen.go (2)

78-81: LGTM!

The addition of the ProfileMention constant to the NotificationEvent type looks good. It aligns with the PR objective to add mentions and enhance the notification system's capabilities.


22040-22185: Skipped review of auto-generated swagger spec.

The changes to the embedded swagger specification are auto-generated and do not directly impact the application logic. Reviewing the specifics of the swagger spec is out of scope for this code review.

Comment on lines +22 to +32
func (n *Mentioner) Send(ctx context.Context, source datagraph.Ref, items ...*datagraph.Ref) {
for _, i := range items {
err := n.q.Publish(ctx, mq.Mention{
Source: source,
Item: *i,
})
if err != nil {
n.l.Error("failed to publish mention message", zap.Error(err))
}
}
}
Copy link

Choose a reason for hiding this comment

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

LGTM, but consider returning the error.

The Send method is well-implemented, iterating over the provided item references and publishing a mention message for each one.

However, consider returning the error to the caller instead of just logging it. This will allow the caller to handle the error appropriately and maintain better control flow.

Here's a suggested refactor:

-func (n *Mentioner) Send(ctx context.Context, source datagraph.Ref, items ...*datagraph.Ref) {
+func (n *Mentioner) Send(ctx context.Context, source datagraph.Ref, items ...*datagraph.Ref) error {
 	for _, i := range items {
 		err := n.q.Publish(ctx, mq.Mention{
 			Source: source,
 			Item:   *i,
 		})
 		if err != nil {
 			n.l.Error("failed to publish mention message", zap.Error(err))
+			return err
 		}
 	}
+	return nil
 }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (n *Mentioner) Send(ctx context.Context, source datagraph.Ref, items ...*datagraph.Ref) {
for _, i := range items {
err := n.q.Publish(ctx, mq.Mention{
Source: source,
Item: *i,
})
if err != nil {
n.l.Error("failed to publish mention message", zap.Error(err))
}
}
}
func (n *Mentioner) Send(ctx context.Context, source datagraph.Ref, items ...*datagraph.Ref) error {
for _, i := range items {
err := n.q.Publish(ctx, mq.Mention{
Source: source,
Item: *i,
})
if err != nil {
n.l.Error("failed to publish mention message", zap.Error(err))
return err
}
}
return nil
}

Comment on lines +24 to +33
func (s *mentionConsumer) mention(ctx context.Context, source datagraph.Ref, item datagraph.Ref) error {
switch item.Kind {
case datagraph.KindProfile:
s.notifySender.Send(ctx, account.AccountID(item.ID), notification.EventProfileMention, &source)

// TODO: Store mention in db
}

return nil
}
Copy link

Choose a reason for hiding this comment

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

LGTM, but implement the TODO.

The mention method is correctly defined and handles the mention based on the Kind field of the item argument. However, the TODO comment indicates that the mention should be stored in the database, which is not implemented yet.

Do you want me to generate the code to store the mention in the database or open a GitHub issue to track this task?

@Southclaws Southclaws merged commit 3c953e2 into main Sep 12, 2024
5 checks passed
@Southclaws Southclaws deleted the mentions branch September 12, 2024 08:23
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.

1 participant