-
Notifications
You must be signed in to change notification settings - Fork 305
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
: Allow user to forward messages
#10331
base: develop
Are you sure you want to change the base?
Conversation
…e-message-view' into feature/communication/consecutive-message-view
…-view # Conflicts: # src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.ts # src/main/webapp/app/shared/metis/answer-post/answer-post.component.scss
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.
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.
Tested on TS3, works!
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.
On TS3: WORKS!
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.
Tested on TS2, works perfectly fine.
When I forward a message with no content to a user which I have not talked to yet, the chat does not appear in the "Direct messages" section. Only after forwarding a message with content added the chat appears and both forwarded messages as well. Not sure if this is intended.
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.
Tested on TS2, works as expected 👍
# Conflicts: # src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html
565c285
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: 1
♻️ Duplicate comments (2)
src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts (2)
718-727
:⚠️ Potential issueFix incorrect expectations in ANSWER postingType test.
The test case for ANSWER postingType has incorrect expectations. It should check
referencePostId
for focusing and verify the conversation ID.Apply this diff to fix the test:
it('should set openThreadOnFocus = true if postingType is ANSWER', () => { const post = { id: 1, postingType: PostingType.ANSWER, - post: { id: 2 } as Post, + referencePostId: 2, + conversation: { id: 1 } as Conversation, } as Posting; component.onTriggerNavigateToPost(post); + expect(component.openThreadOnFocus).toBeTrue(); + expect(component.focusPostId).toBe(2); + expect(setActiveConversationSpy).toHaveBeenCalledWith(1); });
762-777
:⚠️ Potential issueFix incorrect expectations in combined logic test.
The test case for combined logic has incorrect expectations. The
openThreadOnFocus
should betrue
for ANSWER postingType.Apply this diff to fix the test:
it('should combine logic: set focusPostId and only set conversation if ID is present', () => { const post = { id: 10, referencePostId: 888, postingType: PostingType.ANSWER, conversation: { id: 444, }, } as Posting; component.onTriggerNavigateToPost(post); - expect(component.focusPostId).toBe(10); - expect(component.openThreadOnFocus).toBeFalse(); + expect(component.focusPostId).toBe(888); + expect(component.openThreadOnFocus).toBeTrue(); expect(setActiveConversationSpy).toHaveBeenCalledWith(444); });
🧹 Nitpick comments (1)
src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts (1)
700-707
: Improve test suite setup.The test suite setup can be optimized by moving common setup code to the
beforeEach
block.Add spy setup to the
beforeEach
block:beforeEach(() => { fixture = TestBed.createComponent(CourseConversationsComponent); component = fixture.componentInstance; + setActiveConversationSpy = jest.spyOn(metisConversationService, 'setActiveConversation'); }); +afterEach(() => { + jest.clearAllMocks(); +});
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/main/resources/config/liquibase/master.xml
is excluded by!**/*.xml
📒 Files selected for processing (2)
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html
(1 hunks)src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html
🧰 Additional context used
📓 Path-based instructions (1)
`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/overview/course-conversations/course-conversations.component.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Call Build Workflow / Build and Push Docker Image
- GitHub Check: Call Build Workflow / Build .war artifact
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: client-tests-selected
- GitHub Check: client-tests
- GitHub Check: server-style
- GitHub Check: server-tests
- GitHub Check: Analyse
🔇 Additional comments (1)
src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts (1)
700-778
: Test suite needs improvements for better coverage and consistency.The test suite for
onTriggerNavigateToPost
has the same issues as mentioned in the past review comments:
- Incorrect expectations for ANSWER type
- Missing test cases for error handling
- Repeated test setup
Please refer to the previous review comments for the suggested fixes.
...vascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts
Show resolved
Hide resolved
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: 0
🧹 Nitpick comments (1)
src/main/java/de/tum/cit/aet/artemis/communication/web/AnswerMessageResource.java (1)
109-141
: LGTM! Well-implemented endpoint with proper validation and error handling.The implementation follows REST best practices with appropriate security checks, input validation, and error handling.
Consider adding pagination and request limits.
To ensure scalability and prevent potential abuse:
- Consider paginating the results for large lists of IDs
- Add a maximum limit to the number of IDs that can be requested in a single call
Example improvement:
@GetMapping("communication/courses/{courseId}/answer-messages-source-posts") @EnforceAtLeastStudentInCourse -public ResponseEntity<List<AnswerPost>> getSourceAnswerPostsByIds(@PathVariable Long courseId, @RequestParam List<Long> answerPostIds) { +public ResponseEntity<Page<AnswerPost>> getSourceAnswerPostsByIds( + @PathVariable Long courseId, + @RequestParam List<Long> answerPostIds, + @RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "20") int size) { log.debug("GET getSourceAnswerPostsByIds invoked for course {} with {} posts", courseId, answerPostIds.size()); long start = System.nanoTime(); + final int MAX_IDS = 100; + if (answerPostIds.size() > MAX_IDS) { + throw new BadRequestAlertException( + String.format("Cannot request more than %d posts at once", MAX_IDS), + answerMessageService.getEntityName(), + "tooManyIds" + ); + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/tum/cit/aet/artemis/communication/web/AnswerMessageResource.java
(3 hunks)
🧰 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/web/AnswerMessageResource.java
⏰ Context from checks skipped due to timeout of 90000ms (9)
- 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-style
- GitHub Check: server-tests
- GitHub Check: server-style
- GitHub Check: client-tests
- GitHub Check: Analyse
🔇 Additional comments (2)
src/main/java/de/tum/cit/aet/artemis/communication/web/AnswerMessageResource.java (2)
7-7
: LGTM! Import statements follow best practices.The new imports are specific, necessary, and well-organized, following Java coding guidelines.
Also applies to: 15-15, 21-21, 26-27, 29-30
42-50
: LGTM! Constructor follows dependency injection best practices.The constructor properly initializes new dependencies using constructor injection, and fields are marked as final for immutability.
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.
Tested on TS2. Works as described
Checklist
General
Server
Client
Motivation and Context
Currently user cannot forward messages to other channels/direct-group chats.
(Closes #9066)
Description
The forward message feature has been added. Users can now navigate to the forward message dialog by clicking on the forward message option. They can select a random number of destinations and add content to the forwarded message (similar to Slack).
forwarded_message
table has been added to the database with the following fields:post
andanswer_post
table have been updated with a new column named has_forwarded_messages.Known Issue for a followup PR:
The server-side changes for forwarding multiple messages within a single message and forwarding a message as a reply to another message (inside an AnswerPost) are already in place, but the client-side implementation is not ready yet. To achieve this, a unique message link needs to be generated for each post/answer post, similar to the "Copy Link" feature in Slack. This will be completed in a follow-up PR.
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Performance Tests
Test Coverage
Client
Server
Screenshots
forwarded message view

forward message dialog

Summary by CodeRabbit
New Features
Bug Fixes
Tests
ForwardedMessageService
,PostService
, and related components to ensure robust handling of forwarding functionality.