Skip to content

Conversation

@Pdzly
Copy link
Member

@Pdzly Pdzly commented Jul 26, 2024

Closes #446

Pdzly added 8 commits July 23, 2024 11:17
Removed the CommentSave table and replaced it with a more generic LinkPersonComment table. Adjustments were also made to associated event classes, services, and repositories. Moreover, renamed the CommentSave entity to LinkPersonComment in the database and added a new link_type column. This change allows additional person-comment link types to be handled in the future beyond just saving comments.

Signed-off-by: rooki <rooki@rooki.xyz>
CommentSave and PostSave Services, events, and related entities have been refactored and renamed to reflect better usage of "Link" concept. This includes renaming "CommentSaveService" to "LinkPersonCommentService" and "PostSaveService" to "LinkPersonPostService". Functions within these services have also been restructured and properly re-implemented to adhere to new service contracts.

Signed-off-by: rooki <rooki@rooki.xyz>
The LinkPersonPostRepository has been moved from the post/repositories directory to person/repositories and associated methods have been updated accordingly. The PostController class has been refactored to handle post links instead of post saves. The LemmyPostService now calculates unread comments based on comment reads and removed state, and updates associated in the PostView model. Other minor changes include code cleanup in LemmyPostReportService and correcting imports in various classes.

Signed-off-by: rooki <rooki@rooki.xyz>
The code formatting in the ExpiredRoleScheduler class has been tidied up for better readability. The warning message when the default role is not found has also been updated to indicate that this is expected during the initial application start-up.

Signed-off-by: rooki <rooki@rooki.xyz>
…ure/446-comment-post-saves

# Conflicts:
#	src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/post/services/LemmyPostService.java
#	src/main/resources/db/migration/V20231003__Create_initial_entity_tables.sql
#	src/main/resources/db/migration/V20231006__Create_foreign_key_references.sql
Refactored link management methods across various services to use streamlined logic and improved consistency. Enhanced database schema with new indices, added support for link events, and optimized persistence calls.

Signed-off-by: rooki <rooki@rooki.xyz>
…ure/446-comment-post-saves

# Conflicts:
#	src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/community/controllers/CommunityController.java
@Pdzly Pdzly self-assigned this Jul 26, 2024
Pdzly added 7 commits July 26, 2024 09:18
Switched method arguments and refactored linking logic in multiple services for consistency and improved clarity. Added new deleteLink implementations, adjusted method calls, and updated entity mapping for better maintainability.

Signed-off-by: rooki <rooki@rooki.xyz>
…mmentService`

Simplify line formatting for conversion calls and improve readability. Added conditional checks to prevent redundant link checks when the creator is an admin or banned in `LemmyCommentService`.

Signed-off-by: rooki <rooki@rooki.xyz>
Refactor method to check link between community and person for moderator/owner roles. Improve annotations formatting in controllers to enhance readability. Remove unused repository fields in LemmyCommentService.

Signed-off-by: rooki <rooki@rooki.xyz>
Standardize the HttpStatus.UNAUTHORIZED error messages across multiple controllers by changing specific messages like "not_an_admin" and "not_allowed" to a uniform "unauthorized" message. This enhances consistency and simplifies maintenance of error responses.

Signed-off-by: rooki <rooki@rooki.xyz>
Improves link management across various services by introducing refresh methods to handle EntityManager updates. Simplifies existing methods and ensures data consistency through immediate persistence and state refresh operations.

Signed-off-by: rooki <rooki@rooki.xyz>
Refactored multiple services and repositories to improve code readability and maintainability including formatting for better line breaks. Replaced deprecated refresh logic with streamlined data handling and enhanced method signatures for better context.

Signed-off-by: rooki <rooki@rooki.xyz>
Refactored `getPersonPosts` and `getPersonComments` methods to use detailed search criteria. Introduced a `setSavedOnly` method in `PostSearchQueryService` and created `CommentSortTypeSortMapper` for better sorting flexibility.

Signed-off-by: rooki <rooki@rooki.xyz>
@Pdzly Pdzly marked this pull request as ready for review July 28, 2024 18:18
@Pdzly Pdzly requested a review from a team as a code owner July 28, 2024 18:18
Copy link
Member

@lazyguru lazyguru left a comment

Choose a reason for hiding this comment

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

I left some comments, please push back if there are good reasons for keeping the code the way it is.


logger.warning("Default registered role not found.");
logger.warning(
"Default registered role not found. (Expected if it is your initial start of the application.)");
Copy link
Member

Choose a reason for hiding this comment

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

Is there not a way to detect this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really without having another table that has something in it.

public interface LinkPersonCommentRepository extends JpaRepository<LinkPersonComment, Long> {


Optional<LinkPersonComment> getLinkPersonCommentByCommentAndPersonAndLinkType(Comment comment,
Copy link
Member

Choose a reason for hiding this comment

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

I forget that Java supports method overloading. Do we really need to have all of these methods have different names? Why not just have getLinkPersonComment and multiple different signatures?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is jpa? Or i could of course make custom query with @query but then we will have to do this on every other repository too.

Copy link
Member

Choose a reason for hiding this comment

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

Something to discuss with @jgrim I think

Replaced method definition with a JPQL query to count comments by person, post, and removed state. Updated the LemmyPostService to call the refactored repository method.

Signed-off-by: rooki <rooki@rooki.xyz>
@Pdzly Pdzly merged commit 791a596 into main Aug 4, 2024
@Pdzly Pdzly deleted the feature/446-comment-post-saves branch August 4, 2024 18:38
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.

Implement Comment and Post Save

3 participants