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

Communication: Add send as direct message option for replies #10420

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Feb 27, 2025

Checklist

General

Server

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Currently, when replying to a message, the response is always created as an AnswerPost. However, there is no option to post the reply as a regular Post instead. This limitation is not always ideal in scenarios where the reply is relevant to the entire conversation rather than just being tied to the original message.

Description

This PR introduces "Also send as direct message" option when writing a reply.

  • A checkbox has been added below the input field for replies.
  • When selected, the reply is sent both as an AnswerPost and as a regular Post within the same conversation.
  • The Post version of the reply includes a link to navigate to the related thread, similar to Slack.

To achieve this feature, an original_answer_id column has been added to the Post table. This column stores the IDs of answers that have been sent both as an AnswerPost and as a regular Post, allowing seamless navigation between the post and its corresponding thread.

Steps for Testing

Prerequisites:

  • 1 User
  • 1 Course with Communication enabled
  1. Log in to Artemis.
  2. Navigate to the Communication section of a course.
  3. Select a message and type a reply in the input field.
  4. Before sending, check the "Also Send as Direct Message" checkbox below the input field.
  5. Verify that the reply is sent both as an AnswerPost and as a regular Post in the same conversation.
  6. Locate the "replied to a thread" line above the post.
  7. Click the "replied to a thread" link and confirm that it navigates to the original thread.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
post.model.ts 100%
course-conversations.component.ts 90.41% ✅ ❌
message-reply-inline-input.component.ts 81.25% ✅ ❌
post.component.ts 93.19% ✅ ❌
posting-reactions-bar.component.ts 85.82% ✅ ❌

Screenshots

reply input with checkbox
image

navigation link to the thread
image

Summary by CodeRabbit

  • New Features

    • Added an option to send messages as direct messages via a new UI toggle.
    • Enhanced posts with a visible reply context to better indicate threaded discussions.
    • Introduced a new feature to view threads in the post section.
  • Style/UI Enhancements

    • Improved layouts for message replies and threaded views, offering clearer navigation and readability.
    • Refined styling for text display to ensure consistent alignment and responsiveness.
  • Localization

    • Updated language entries in both English and German to reflect the new messaging and thread viewing options.
  • Tests

    • Expanded test coverage to validate direct messaging, form reset, and replying behavior.

@asliayk asliayk added feature tests client Pull requests that update TypeScript code. (Added Automatically!) labels Feb 27, 2025
@asliayk asliayk self-assigned this Feb 27, 2025
@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. communication Pull requests that affect the corresponding module labels Feb 27, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test2.artemis.cit.tum.de March 2, 2025 09:56 Inactive
@asliayk asliayk marked this pull request as ready for review March 2, 2025 10:00
@asliayk asliayk requested a review from a team as a code owner March 2, 2025 10:00
Copy link

coderabbitai bot commented Mar 2, 2025

Walkthrough

The changes update serialization configurations in backend domain models, add a new field to store an original answer identifier, and propagate these modifications through related model classes. The UI components are updated with conditional logic for handling direct messaging, thread replies, and active conversation management. Additionally, new CSS classes improve layout styling and i18n keys are added for new user messages. The tests are extended to cover the new behaviors in the messaging and post components.

Changes

File(s) Change Summary
src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java
src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java
AnswerPost.java: Updated @JsonIncludeProperties annotation to include "content".
Post.java: Removed hasForwardedMessages, added private Long originalAnswerId with associated getter and setter.
src/main/webapp/app/entities/metis/post.model.ts Added optional properties isConsecutive?: boolean (default false) and originalAnswerId?: number to the Post class.
src/main/webapp/app/overview/course-conversations/course-conversations.component.ts Modified active conversation logic: adds a conditional check and uses setTimeout when the selected conversation matches the active one.
src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.html
src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts
HTML: Reorganized layout; removed text-end class; added a new wrapper for buttons and a conditional checkbox for sending as direct message.
TS: Introduced the signal sendAsDirectMessage, added toggleSendAsDirectMessage(), and updated createPosting to incorporate logic for direct messaging along with new helper methods (mapAnswerPostToPost, finalizeCreation).
src/main/webapp/app/shared/metis/post/post.component.html
src/main/webapp/app/shared/metis/post/post.component.ts
HTML: Adjusted conditional rendering for posting headers and added a block to display a reply-to indicator with a link.
TS: Injected AnswerPostService, added an optional property to store the original answer, and implemented loadOriginalAnswerContent() to fetch and assign original answer details.
src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html
src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts
HTML: Refined condition for button display by adding checks for !originalAnswerId and sidebar type.
TS: Added a new property originalAnswerId and assigned it from the posting object.
src/main/webapp/app/shared/metis/post/post.component.scss Added new CSS classes .flex-wrapper, .replied-text, and .one-line to improve layout and text overflow styling.
src/main/webapp/i18n/de/conversation.json
src/main/webapp/i18n/en/conversation.json
src/main/webapp/i18n/de/metis.json
src/main/webapp/i18n/en/metis.json
Added new translation keys: "sendAsDirectMessage" in conversation files; "viewThread" and "repliedToThread" (plus a minor formatting update for "saved") in metis files.
src/test/javascript/spec/component/shared/metis/message-reply-inline-input/message-reply-inline-input.component.spec.ts Added new tests for toggling sendAsDirectMessage, resetting the form group, and verifying direct message posting behavior (with necessary import adjustments).
src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts Introduced new HTTP client testing providers and a mock ResizeObserver to enhance the testing setup.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as MessageReplyInlineInputComponent
    participant S as MetisService
    participant A as AnswerPost

    U->>M: Toggle direct message option
    M->>M: toggleSendAsDirectMessage()
    U->>M: Submit form (createPosting)
    alt sendAsDirectMessage true
        M->>M: mapAnswerPostToPost(AnswerPost)
        M->>S: createAnswerPost$ observable
        S-->>M: AnswerPost data
        M->>M: finalizeCreation()
        M-->>U: Emit created AnswerPost (onCreate event)
    else sendAsDirectMessage false
        M->>S: create Posting normally
        S-->>M: Posting data
        M-->>U: Emit created AnswerPost (onCreate event)
    end
Loading
sequenceDiagram
    participant U as User
    participant C as CourseConversationsComponent
    participant D as ChangeDetector

    U->>C: Navigate to a post with conversation ID
    alt Active Conversation equals selected ID
        C->>C: Set activeConversation to undefined
        C->>C: setTimeout(() => set activeConversation to ID)
        C->>D: Trigger detectChanges()
    else
        C->>C: Set activeConversation to the new ID
        C->>D: Trigger detectChanges()
    end
Loading

Suggested labels

ready to merge

Suggested reviewers

  • HawKhiem
  • sachmii
  • sawys777
  • Cathy0123456789
  • krusche
✨ Finishing Touches
  • 📝 Generate Docstrings

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

Documentation and Community

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/main/webapp/app/overview/course-conversations/course-conversations.component.ts (1)

638-647: Effective solution for handling same-conversation navigation.

The conditional logic ensures proper refreshing when navigating to the same conversation by temporarily setting it to undefined before resetting it. This is a common pattern to force re-renders in Angular applications.

Consider using Angular's change detection API directly for more precise control:

-        if (this.activeConversation && this.activeConversation.id === id) {
-            this.metisConversationService.setActiveConversation(undefined);
-            setTimeout(() => {
-                this.metisConversationService.setActiveConversation(id);
-                this.changeDetector.detectChanges();
-            }, 0);
-        } else {
-            this.metisConversationService.setActiveConversation(id);
-            this.changeDetector.detectChanges();
-        }
+        if (this.activeConversation && this.activeConversation.id === id) {
+            // Mark component for check and trigger change detection cycle
+            this.changeDetector.markForCheck();
+        }
+        this.metisConversationService.setActiveConversation(id);
+        this.changeDetector.detectChanges();
src/main/webapp/app/shared/metis/post/post.component.html (1)

32-43: Good implementation of the reply indicator.

The implementation provides clear visual feedback that the post is a reply to another conversation thread. The clickable link to the original content helps maintain context and aids navigation between related conversations.

Small styling suggestion:

-        <div class="message-container post-content-padding text-muted fs-smaller mt-1">
+        <div class="message-container post-content-padding text-muted fs-smaller mt-1 mb-1">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93eba08 and d50ff6e.

⛔ Files ignored due to path filters (2)
  • src/main/resources/config/liquibase/changelog/20250227143115_changelog.xml is excluded by !**/*.xml
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
📒 Files selected for processing (17)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java (2 hunks)
  • src/main/webapp/app/entities/metis/post.model.ts (1 hunks)
  • src/main/webapp/app/overview/course-conversations/course-conversations.component.ts (1 hunks)
  • src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.html (2 hunks)
  • src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts (5 hunks)
  • src/main/webapp/app/shared/metis/post/post.component.html (3 hunks)
  • src/main/webapp/app/shared/metis/post/post.component.scss (1 hunks)
  • src/main/webapp/app/shared/metis/post/post.component.ts (5 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html (1 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (2 hunks)
  • src/main/webapp/i18n/de/conversation.json (1 hunks)
  • src/main/webapp/i18n/de/metis.json (2 hunks)
  • src/main/webapp/i18n/en/conversation.json (1 hunks)
  • src/main/webapp/i18n/en/metis.json (2 hunks)
  • src/test/javascript/spec/component/shared/metis/message-reply-inline-input/message-reply-inline-input.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`src/main/webapp/**/*.html`: @if and @for are new and valid ...

src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html
  • src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.html
  • src/main/webapp/app/shared/metis/post/post.component.html
`src/main/webapp/i18n/de/**/*.json`: German language transla...

src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

  • src/main/webapp/i18n/de/conversation.json
  • src/main/webapp/i18n/de/metis.json
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

  • src/main/webapp/app/entities/metis/post.model.ts
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts
  • src/main/webapp/app/overview/course-conversations/course-conversations.component.ts
  • src/main/webapp/app/shared/metis/post/post.component.ts
  • src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

  • src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts
  • src/test/javascript/spec/component/shared/metis/message-reply-inline-input/message-reply-inline-input.component.spec.ts
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java
🧠 Learnings (1)
src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (1)
Learnt from: pzdr7
PR: ls1intum/Artemis#9505
File: src/test/javascript/spec/integration/code-editor/code-editor-container.integration.spec.ts:179-181
Timestamp: 2024-11-12T12:51:58.049Z
Learning: In `src/test/javascript/spec/integration/code-editor/code-editor-container.integration.spec.ts`, `ResizeObserver` is mocked within the `beforeEach` block.
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests-selected
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (32)
src/main/webapp/i18n/de/conversation.json (1)

22-22: LGTM! The translation uses the correct informal style.

The German translation correctly uses the informal style (du-form) as required by our coding guidelines. This key properly supports the new "send as direct message" functionality.

src/main/webapp/i18n/en/conversation.json (1)

22-22: LGTM! Translation string correctly added.

The English translation for the new "send as direct message" feature is clear and concise.

src/main/webapp/i18n/en/metis.json (2)

146-146: LGTM! Clear and concise label for thread navigation.

The new translation key provides a clear instruction for users to navigate to the thread view.


156-157: LGTM! Properly structured JSON addition with correct comma placement.

The new translation for thread reply indication and the added comma maintain proper JSON formatting.

src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html (1)

3-3: Logic addition handles original answers and thread views correctly.

The conditional logic now checks for the absence of an original answer ID and ensures the component is not in a thread sidebar before rendering the reply button. This prevents redundant reply options in thread contexts.

src/main/webapp/app/entities/metis/post.model.ts (1)

13-14: Model properties support direct message functionality.

The added properties enhance the Post model:

  • isConsecutive helps with UI display logic for consecutive messages
  • originalAnswerId implements the core functionality by storing the ID of the original answer when a reply is sent as both an AnswerPost and a Post

This aligns perfectly with the PR objective of enabling replies to be sent as both types of messages.

src/main/webapp/app/shared/metis/post/post.component.scss (2)

109-114: Well-structured flex container implementation.

The flex-wrapper provides a clean way to handle the new layout requirements for the thread reply feature.


116-127: Good text handling for thread replies.

These classes appropriately handle text overflow for the reply indicators, preventing layout issues when text is too long. The combination of .replied-text for fixed content and .one-line for expandable content with ellipsis works well for responsive design.

src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (2)

116-116: Property added to support direct message replies.

The originalAnswerId property correctly follows TypeScript conventions and Angular style guidelines.


166-166: Properly initializes originalAnswerId from posting.

The implementation correctly checks if the posting is a post type before assigning the originalAnswerId property.

src/main/webapp/i18n/de/metis.json (2)

146-146: Thread navigation text added correctly.

The German translation uses informal style ("Thread ansehen") as required by the coding guidelines.


156-157: Thread reply message and JSON formatting fixed.

Added proper comma after the "saved" entry and included the new reply notification message in informal German style.

src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java (1)

42-42: Added 'content' to JSON serialization properties.

The addition of "content" to the JsonIncludeProperties annotation is necessary to support the new functionality of showing original answer content in direct message replies.

src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (1)

33-34: Good setup for HTTP client testing and ResizeObserver mock!

The addition of HTTP client testing providers and the ResizeObserver mock implementation are appropriate for testing components that interact with HTTP services and need to handle resize events. This follows best practices for Angular testing.

Also applies to: 54-55, 86-87, 121-123

src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java (2)

107-108: Well-structured database column addition.

The new originalAnswerId field is correctly annotated with @Column and uses the appropriate naming convention for the database column.


253-259: Clean accessor methods implementation.

Standard getter and setter methods following Java conventions for the new originalAnswerId field.

src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.html (1)

15-52: Good implementation of the direct message checkbox feature.

The changes improve the layout using flexbox utilities and add the new "Send as Direct Message" checkbox functionality. The code follows the modern Angular practices by using @if for conditional rendering and proper translation directives for i18n.

src/main/webapp/app/shared/metis/post/post.component.html (2)

18-18: Enhanced conditional rendering logic.

The condition has been updated to display the post header when the post is not consecutive or when it's a reply (has originalAnswerId). This improves the user interface by ensuring proper context is shown for all types of posts.


209-221: Appropriate conditional behavior for thread navigation.

The dropdown now checks if the post is an original post or a reply, and adapts the action accordingly:

  • For original posts: Opens reply thread
  • For posts that are replies (with originalAnswerId): Navigates to the original thread

This creates a consistent user experience and prevents confusion when interacting with different types of posts.

src/main/webapp/app/shared/metis/post/post.component.ts (3)

43-43: Properly imported and injected AnswerPostService.

The service is correctly imported and injected using the modern inject pattern.

Also applies to: 79-79


132-132: Added property to track original answer post.

The optional property is correctly typed and follows camelCase naming convention.


225-225: Properly initialized originalAnswer in ngOnInit.

The method is called at the appropriate lifecycle hook to ensure the data is loaded when the component initializes.

src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts (6)

1-1: Updated imports to support new functionality.

Added necessary imports for the signal API and Post model.

Also applies to: 12-12


30-30: Added signal for tracking direct message preference.

Using Angular's signal API for reactive state management is a good practice.


51-53: Clean implementation of toggle functionality.

The method correctly toggles the signal state using the modern signal API.


73-93: Well-structured implementation for dual posting functionality.

The implementation correctly handles creating both an AnswerPost and a regular Post when sendAsDirectMessage is true. The observable chaining is properly structured with appropriate error handling.


95-99: Good code reuse pattern with finalizeCreation method.

Extracted common logic into a separate method, improving maintainability and readability.


101-107: Properly implemented mapAnswerPostToPost conversion.

The method correctly maps the necessary fields from AnswerPost to Post, ensuring that the originalAnswerId reference is maintained.

src/test/javascript/spec/component/shared/metis/message-reply-inline-input/message-reply-inline-input.component.spec.ts (4)

10-10: Updated imports to support new tests.

Added necessary imports for rxjs operators and the AnswerPost model.

Also applies to: 16-16


131-137: Well-implemented test for toggle functionality.

The test properly verifies the initial state and the effect of toggling the sendAsDirectMessage signal.


139-144: Good coverage for resetFormGroup functionality.

The test verifies both the posting.content update and the form control value update.


146-171: Comprehensive test for direct message creation.

The test properly:

  1. Sets up the component state with the required data
  2. Mocks the service responses
  3. Verifies the correct parameters are passed to createPost
  4. Checks that the onCreate event is emitted with the right data
  5. Confirms that loading state is properly reset

Great job ensuring thorough test coverage for this critical feature.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 2, 2025
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: 0

🧹 Nitpick comments (1)
src/main/java/de/tum/cit/aet/artemis/communication/domain/Posting.java (1)

128-134: Consider using 'is' prefix for boolean getters.

While the code functions correctly, Java conventions typically recommend using the 'is' prefix rather than 'get' for boolean property getters. Consider renaming getHasForwardedMessages() to isHasForwardedMessages() for better compliance with Java bean naming conventions.

-public boolean getHasForwardedMessages() {
+public boolean isHasForwardedMessages() {
    return hasForwardedMessages;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d50ff6e and 05184b9.

📒 Files selected for processing (4)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Posting.java (2 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/AnswerPost.java
  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Post.java
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/communication/domain/Posting.java
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-compilation
  • GitHub Check: client-tests-selected
  • GitHub Check: client-tests
  • GitHub Check: client-style
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: Analyse
🔇 Additional comments (3)
src/main/java/de/tum/cit/aet/artemis/communication/domain/Posting.java (3)

63-64: Field addition addresses cross-cutting functionality.

Adding the hasForwardedMessages field to the Posting base class is a good refactoring decision. This eliminates duplication by moving a common field from both Post and AnswerPost subclasses to their shared parent, following the DRY (Don't Repeat Yourself) principle.


63-134: Feature connection to PR objectives.

This change supports the PR objective of sending replies as both an AnswerPost and a regular Post. The hasForwardedMessages field will track when a message has been duplicated across post types, enabling the "Also send as direct message" functionality described in the PR objectives.


63-134:

❓ Verification inconclusive

Verify database migration for schema changes.

This change introduces a new column at the Posting level that was previously in child entities. Ensure there's a corresponding database migration script to handle this schema change correctly, especially concerning existing data.


🏁 Script executed:

#!/bin/bash
# Check for migration files that handle this schema change
rg -l "has_forwarded_messages" --type-add 'sql:*.sql' --type sql src/main/resources/config/liquibase/

Length of output: 101


Action Required: Verify Database Migration for New Column on Posting

The new has_forwarded_messages column in the Posting entity must have an associated migration to handle existing data. Our initial search in the Liquibase migration files did not return any scripts referencing this column. Please manually verify that a database migration script exists to update the schema accordingly and that existing records are appropriately handled.

Copy link
Contributor

@cremertim cremertim left a comment

Choose a reason for hiding this comment

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

Great work 👍 Code looks good to me

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Looks good, I left a few comments

@@ -26,6 +27,8 @@ export class MessageReplyInlineInputComponent extends PostingCreateEditDirective

@Output() valueChange = new EventEmitter<void>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also adapt this here, to use input... ?

@@ -113,6 +113,7 @@ export class PostingReactionsBarComponent<T extends Posting> implements OnInit,
canPin = false;
channels: ChannelDTO[] = [];
users: UserPublicInfoDTO[] = [];
originalAnswerId: number | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use this here:

Suggested change
originalAnswerId: number | undefined;
originalAnswerId?: number;

does it even need to be undefined here?

Comment on lines +26 to +34
@if (editType !== EditType.UPDATE) {
<div class="direct-message-checkbox">
<input type="checkbox" id="directMessageCheckbox" [checked]="sendAsDirectMessage()" (change)="toggleSendAsDirectMessage()" />
<label for="directMessageCheckbox" jhiTranslate="artemisApp.conversationsLayout.sendAsDirectMessage"></label>
</div>
}

<div class="d-flex gap-2">
@if (editType === EditType.UPDATE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here it would possibly make sense to only use the first condition and then use @else

@helios-aet helios-aet bot temporarily deployed to artemis-test5.artemis.cit.tum.de March 7, 2025 14:32 Inactive
Copy link
Contributor

@PaRangger PaRangger left a comment

Choose a reason for hiding this comment

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

Tested on TS5. Really cool new feature 😄 Everything works great, except one thing: When I "send as direct message" in a thread that has a formatted message, it will show the link to that message unfromatted. I think generally that would be okay, just the markdown should not be shown.

Bildschirmfoto 2025-03-07 um 15 47 27

Edit: But I would also think its okay if we do not even show the message content at all and just make the "thread" in "replied to a thread" a link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) communication Pull requests that affect the corresponding module database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. feature ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants