-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughWalkthroughThe changes primarily involve a transition from the Changes
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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
app/services/mention/mention_job/job.go (1)
33-35
: Consider handling the error returned by theic.mention
method.Currently, if the
ic.mention
method returns an error, it is only logged using thezap
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
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 theeventEnum
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 formq.Mention
, anewMentionConsumer
function, invocation ofrunMentionConsumer
, and amentioner.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 newMentioner
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 thementionConsumer
struct. It correctly initializes the struct with the providednotifySender
argument and returns a pointer to a newmentionConsumer
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 theNotificationEvent
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 theent
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 thecontent
package to thedatagraph
package.The import statement for the
content
package has been removed and thedatagraph
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 thedatagraph
package instead.Run the following script to verify the package usage:
Verification successful
Transition from
content
todatagraph
package verified successfully.The transition from the
content
package to thedatagraph
package for handling rich text content has been successfully implemented across the codebase. Thecontent
package is no longer in use, and thedatagraph
package is widely adopted, with thedatagraph.Content
type replacingcontent.Rich
.
- No instances of
github.com/Southclaws/storyden/app/resources/content
orcontent.Rich
were found.- The
datagraph
package anddatagraph.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 theBio
field type change is handled correctly.The
Bio
field in theAccount
struct has been changed fromcontent.Rich
todatagraph.Content
. This change aligns with the transition from thecontent
package to thedatagraph
package for handling rich text content.Verify that all code that interacts with the
Bio
field has been updated to handle the newdatagraph.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 theAdd
method signature is approved. It aligns the type withxid.ID
, which is used consistently for identifiers in the codebase.
25-25
: Looks good!The change to the
owner
parameter type in theRemove
method signature is approved. It maintains consistency with theAdd
method and the usage ofxid.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 neweventProfileMention
event type.app/resources/post/reply/repo.go (2)
10-10
: LGTM!The import statement change from
content
todatagraph
is approved. This change aligns with the shift in the source of theContent
type used in theWithContent
function.
38-38
: LGTM!The function signature change for
WithContent
to accept a parameter of typedatagraph.Content
instead ofcontent.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 theRichText
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 theaccountID
type.Ensure that changing the
accountID
parameter type fromaccount.AccountID
toxid.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 theAdd
function.This change aligns with the previous modification to the
accountID
parameter type in theAdd
function. Refer to the comments made for that change.app/resources/account/mapping.go (2)
11-11
: LGTM!The import statement change from
content
todatagraph
is approved.
21-21
: LGTM, but verify the functionality.The change to use
datagraph.NewRichText
instead ofcontent.NewRichText
is approved.However, ensure that the functionality of the
NewRichText
function in thedatagraph
package matches the previous implementation in thecontent
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
todatagraph
is approved. It aligns with the update to theWithContent
function signature and suggests a shift in the source of theContent
type.
31-31
: LGTM, but verify the usage ofdatagraph.Content
.The function signature change from
content.Rich
todatagraph.Content
is approved. It aligns with the import statement update and suggests a shift in the source of theContent
type.However, ensure that the
datagraph.Content
type is thoroughly tested and provides the necessary functionality for theWithContent
function. Verify that all usages ofWithContent
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 usedatagraph.Content
consistently across the codebase. The methodsHTML()
andShort()
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 thefault
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 ofGetContent
.The return type of the
GetContent
method in theWithContent
interface has been changed fromcontent.Rich
toContent
. 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 theRef
type and associated functionality.The removal of the
Ref
type, its associated methodsGetID
andGetKind
, and theNewRef
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 thecontent
package to thedatagraph
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 updatedContent
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 thedatagraph
package, are approved. This refactoring effort is consistent with the update to theNewRichText
function call later in the file.
51-51
: LGTM!The change to the
NewRichText
function call, replacingcontent.NewRichText
withdatagraph.NewRichText
, is approved. This update is consistent with the refactoring effort to move the rich text processing functionality from thecontent
package to thedatagraph
package.app/resources/datagraph/content_test.go (4)
6-7
: LGTM!The new import statements for
utils
andxid
packages are approved.
12-17
: LGTM!The changes in the
check
function to use theContent
type instead of theRich
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 theRefList
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 tosql.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
todatagraph
is approved. It aligns with the PR objective of transitioning to thedatagraph
package.
48-48
: LGTM!The change in the
ReplyCreate
function to usedatagraph.NewRichText
instead ofcontent.NewRichText
is approved. It aligns with the import statement change and the PR objective of transitioning to thedatagraph
package. The overall functionality of theReplyCreate
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. Thethr.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
todatagraph
is approved. It aligns with the overall transition to thedatagraph
package for content representation.
48-48
: LGTM, but verify the function usage.The function signature change of
WithContent
to acceptdatagraph.Content
instead ofcontent.Rich
is approved. It aligns with the overall transition to thedatagraph
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 correctdatagraph.Content
type.Run the following script to verify the function usage:
Verification successful
Function usage verified.
The
WithContent
function is correctly used with thedatagraph.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 fromcontent
todatagraph
.The import statement for the
content
package has been replaced with thedatagraph
package, and theContent
field in theWebContent
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
toMentionProfile
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 wrapaccountID
withxid.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 thedatagraph
package for handling rich text content. This is reflected in:
- The
Bio
field type in thePublic
struct.- The
GetContent()
method signature.- The
ProfileFromModel
function's usage ofdatagraph.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 thedatagraph.Content
type in thePartial
struct.
38-38
: LGTM!The changes to the
Partial
struct andOpts()
method are consistent and correctly reflect the shift from using thecontent
package to thedatagraph
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 theBuild
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 betweenPost
andMentionProfile
entities. The cascading delete annotation ensures data integrity.app/resources/library/library.go (2)
10-10
: LGTM!The import statement change from
content
todatagraph
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 withdatagraph.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 thedatagraph
package for content handling.
45-52
: LGTM!The
GetContent
method andMap
function changes are approved. They align with the transition from thecontent
package to thedatagraph
package for content handling.Also applies to: 73-73
32-32
: LGTM, but verify the field usage.The
Content
field type change fromcontent.Rich
todatagraph.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 fromcontent.Rich
todatagraph.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 thedatagraph
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 thegetArticleContent
function call and the derivation of thetext
variable from therc.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 thedatagraph
package and the utilization ofdatagraph.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 thedatagraph
package import are consistent with the transition from thecontent
package to thedatagraph
package.Also applies to: 15-15
73-73
: LGTM!The changes in the
FromModel
function are approved. The replacement of thecontent.NewRichText
function call withdatagraph.NewRichText
is consistent with the transition from thecontent
package to thedatagraph
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 thedatagraph
package instead of thecontent
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 theNewRichText
function is now being provided by thedatagraph
package instead of thecontent
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 thecontent
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 inapp/resources/seed/account.go
, as theBio
field is of typedatagraph.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.goLength 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 10Length of output: 2752
app/resources/post/thread/thread.go (1)
86-86
: LGTM, but verify theNewRichText
function usage.The change to use the
datagraph
package for theNewRichText
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 thedatagraph
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 thedatagraph
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 thedatagraph
package, and thementioner
package has been added to support the new mentioning functionality.Also applies to: 25-25
61-61
: LGTM!The
Partial
struct change is approved. TheContent
field type has been correctly updated toopt.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 todatagraph.Content
to reflect the package replacement.
92-92
: LGTM!The
service
struct andNew
function changes are approved. The newmentioner
field has been correctly added to theservice
struct, and theNew
function has been updated to accept and initialize thementioner
parameter.Also applies to: 104-104, 114-114
app/resources/post/thread/repo.go (2)
12-12
: LGTM!The import statement change from
content
todatagraph
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 typedatagraph.Content
instead ofcontent.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 typedatagraph.Content
is consistently applied across the codebase. The usage ofdatagraph.Content
is widespread and integrated, indicating that the transition fromcontent.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 thepolicy
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 toContent
, the addition of thesdrs
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 newNewRichTextFromReader
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 theContent
type by providing a summary generation capability.app/transports/http/bindings/threads.go (3)
59-59
: LGTM!The change from
content.NewRichText
todatagraph.NewRichText
in theThreadCreate
method is approved.
107-107
: LGTM!The change from
content.NewRichText
todatagraph.NewRichText
in theThreadUpdate
method is approved.
16-17
: LGTM, but verify the usage of thedatagraph
package.The import statement change from
content
todatagraph
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
PackageThe
datagraph.NewRichText
function is used consistently across the codebase, confirming that the transition from thecontent
package to thedatagraph
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 fieldsid
,created_at
,account_id
, andpost_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 thedatagraph
package import. This change suggests a refactoring to use thedatagraph
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 typedatagraph.Content
instead ofcontent.Rich
. This change aligns with the package import update fromcontent
todatagraph
.app/services/library/node_mutate/node.go (2)
19-19
: LGTM!The import statement change from
content
todatagraph
is approved.
46-46
: LGTM!The changes in the
Partial
struct andOpts()
method to use thedatagraph.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 ofdatagraph.NewRichText
in thefromRow
function.
150-150
: Verify the impact of thedatagraph
transition.The
content.NewRichText
function call has been replaced withdatagraph.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:
Confirm that the
datagraph.NewRichText
function has the same behavior and output as the previouscontent.NewRichText
function.Identify all the places where the
OwnerBio
data is used or displayed and ensure that the transition todatagraph
does not introduce any regressions or unexpected changes.Review the relevant documentation and update it to reflect the transition from
content
todatagraph
for rich text processing.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 theTx
struct is approved. This change expands the capabilities of theTx
struct to handle MentionProfile-related operations.
197-197
: LGTM!The initialization of
tx.MentionProfile
in theinit
method of theTx
struct is approved. This change ensures that theMentionProfile
client is properly instantiated alongside the other clients.app/resources/seed/post.go (4)
12-12
: LGTM!The change from the
content
package to thedatagraph
package for handling rich text content is approved.
33-33
: LGTM!The change to use
datagraph.NewRichText
for initializing theContent
field is approved.
73-73
: LGTM!All the changes to use
datagraph.NewRichText
for initializing theContent
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 oft.Author.ID
for the author ID argument in thear.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 asID
,CreatedAt
,AccountID
, andPostID
.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
, andNot
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 thedatagraph
package import aligns with the objective of transitioning to thedatagraph
package for handling rich text content.
69-69
: LGTM!The
NewRichText
function usage changes in theNodeCreate
andNodeUpdate
methods are approved. Using thedatagraph
package instead of thecontent
package for theNewRichText
function aligns with the import statement changes and the objective of transitioning to thedatagraph
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 itsMutate
method follow the established pattern in this file. They enhance the flexibility of mutation handling for theMentionProfile
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 theAccountEdges
struct and the corresponding increase in the size of theloadedTypes
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 theAccountEdges
struct. It correctly checks theloadedTypes
array at index 8 to determine if theMentions
field has been loaded.
367-370
: LGTM!The
QueryMentions
method implementation is consistent with the other similar query methods in theAccount
struct. It correctly uses theNewAccountClient
to create a query for the "mentions" edge.
65-66
: Verify the usage of the newMentions
field andQueryMentions
method.Please ensure that the new
Mentions
field in theAccountEdges
struct and theQueryMentions
method in theAccount
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 andQueryMentions
method are used correctly.The
Mentions
field in theAccountEdges
struct and theQueryMentions
method in theAccount
struct are properly integrated and used within the codebase. They are part of the entity and query structures for bothAccount
andPost
, 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
andPost
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
andExec
methods provide more control over the update operation.
337-438
:sqlSave
method ofMentionProfileUpdateOne
is correct.The method follows the same patterns as the
sqlSave
method ofMentionProfileUpdate
, 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 formentionprofile.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 thePostEdges
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 thePostEdges
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 existingOrErr
methods for other edges.
198-198
: LGTM!The adjustments to the indices used to check the loading status of the
Assets
,Collections
,Link
, andContentLinks
edges are approved. These changes correctly account for the expansion of theloadedTypes
array due to the addition of theMentions
field.Also applies to: 207-207, 218-218, 227-227
429-432
: LGTM!The addition of the
QueryMentions
method to thePost
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
andByMentions
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 theMentionProfile
schema. The field and edge setting methods,Save
,Exec
, andOnConflict
configuration are implemented as expected by theent
framework.
413-642
: Bulk creation code is properly generated!The
MentionProfileCreateBulk
struct and its methods are generated correctly for handling bulk creation ofMentionProfile
entities. TheSave
method properly iterates over the builders, invokes mutation hooks, and creates entities in bulk. TheOnConflict
configuration for bulk creation is also generated as expected by theent
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
, andMentionsColumn
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 otherByXCount
functions.
385-390
: LGTM!The new
ByMentions
function is correctly implemented and follows the pattern of otherByX
functions.
531-537
: LGTM!The new
newMentionsStep
function is correctly implemented and follows the pattern of othernewXStep
functions.internal/ent/account/where.go (2)
644-652
: LGTM!The
HasMentions
function correctly applies theHasEdge
predicate on the "mentions" edge, following the established pattern in this file.
655-664
: LGTM!The
HasMentionsWith
function correctly extends the functionality ofHasMentions
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 theRefTable
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 theMentionProfile
schema to define fields and default values.- Default values for
created_at
andid
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 theMentionProfile
instances to IDs and delegates the addition toAddMentionIDs
.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 usingMentionProfile
entities directly. By extracting the IDs and callingAddMentionIDs
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 whenMentionIDs
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 newmentions
edge in theAccountQuery
struct.
47-47
: LGTM!The
withMentions
field is correctly added to theAccountQuery
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 theMentionProfileClient
, 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 thesqlAll
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 forPostUpdateOne
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 tosqlSave
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 forAccountUpdateOne
looks good!The method follows the same pattern as the corresponding method in
AccountUpdate
.
1763-1769
:AddMentions
method forAccountUpdateOne
looks good!The method provides a convenient way to add mentions by accepting
MentionProfile
objects directly, similar to the corresponding method inAccountUpdate
.
2035-2038
:ClearMentions
method forAccountUpdateOne
looks good!The method allows clearing all mentions in a single operation, similar to the corresponding method in
AccountUpdate
.
2041-2044
:RemoveMentionIDs
method forAccountUpdateOne
looks good!The method follows the same pattern as the corresponding method in
AccountUpdate
.
2047-2053
:RemoveMentions
method forAccountUpdateOne
looks good!The method provides a convenient way to remove mentions by accepting
MentionProfile
objects directly, similar to the corresponding method inAccountUpdate
.internal/ent/client.go (4)
2430-2438
: LGTM!The declaration of the
MentionProfileClient
struct and theNewMentionProfileClient
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 toAccountClient
andPostClient
looks good. The implementation follows the established patterns and correctly usessqlgraph
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 newMentionProfile
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 theNotificationEvent
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.
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)) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 | |
} |
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
No description provided.