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: Render announcement emails correctly #9520

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

PaRangger
Copy link
Contributor

@PaRangger PaRangger commented Oct 18, 2024

Checklist

General

Server

Motivation and Context

The notification emails sent by the server are currently not rendering correctly. Instead of displaying the content as intended, markdown tags such as double asterisks are visible in the emails. This issue should be resolved so that the notifications are displayed properly, just as they appear in the communication module.
Bildschirmfoto 2024-10-18 um 23 25 02

Description

I used the CommonMark HtmlRenderer to render the content of the notification. This should ensure that standard Markdown elements like bold, italics, and code are displayed correctly.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Course with communication enabled
  1. Log in to Artemis
  2. Navigate to course
  3. Go to communication
  4. Select the "announcement" channel
  5. Write a new announcement and format it using bold, italics, underline, code, codeblock, or quote
  6. Verify that the e-mail that is sent is displayed correctly

Exam Mode Testing

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

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Screenshots

Bildschirmfoto 2024-10-18 um 23 32 28

Summary by CodeRabbit

  • New Features

    • Enhanced email notifications to support markdown content rendering, improving the presentation of posts in emails.
  • Bug Fixes

    • Ensured that if markdown parsing fails, the original content remains unchanged, preventing display issues.

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test4.artemis.cit.tum.de" is already in use by PR #9511.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 18, 2024
@PaRangger PaRangger added deploy:artemis-test3 and removed deployment-error Added by deployment workflows if an error occured labels Oct 18, 2024
@PaRangger PaRangger temporarily deployed to artemis-test3.artemis.cit.tum.de October 18, 2024 21:53 — with GitHub Actions Inactive
@PaRangger PaRangger marked this pull request as ready for review October 18, 2024 22:26
@PaRangger PaRangger requested a review from a team as a code owner October 18, 2024 22:26
Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The MailService class has been updated to support rendering markdown content in email notifications. This involves integrating the Parser and HtmlRenderer from the org.commonmark package to convert markdown into HTML. The sendNotification method now processes the content of posts, rendering it to HTML if it is markdown. If an error occurs during this process, the original content is retained.

Changes

File Path Change Summary
src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java Added imports for Parser and HtmlRenderer, modified sendNotification to parse and render markdown content.

Possibly related PRs

Suggested labels

client

Suggested reviewers

  • edkaya
  • JohannesStoehr
  • pzdr7
  • farisd16

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b52e25e and 02d0290.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java (1)

Pattern 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

Copy link
Member

@krusche krusche left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

@krusche krusche added this to the 7.6.1 milestone Oct 19, 2024
@krusche krusche merged commit 09b0dad into develop Oct 19, 2024
82 of 87 checks passed
@krusche krusche deleted the bugfix/communication/fix-announcment-mail-markdown branch October 19, 2024 12:28
@krusche krusche changed the title Communication: Fix markdown render of announcement e-mail Communication: Render announcement emails correctly Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix communication Pull requests that affect the corresponding module component:Communication ready for review server Pull requests that update Java code. (Added Automatically!) small
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants