-
-
Notifications
You must be signed in to change notification settings - Fork 1k
SAK-52133 Discussions No email notifications are sent if an attachment is added - Fix #14322
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughReplaces immediate attachment cleanup with a scheduled TimerTask (10s delay) to remove files and directories; updates deletion methods to log outcomes and use deleteOnExit() when immediate removal fails; adds Timer/TimerTask imports and debug logging. Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
🤖 Fix all issues with AI agents
In
`@msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java`:
- Around line 272-290: The code risks StringIndexOutOfBounds when extracting the
directory and misuses deleteOnExit for directories; replace manual substring
logic with File file = new File(buildAttachmentPath(resourceId)); File dir =
file.getParentFile(); if dir is null decide a safe default or throw an
IOException, then create dir via dir.exists()/dir.mkdirs() and only call
file.deleteOnExit() (remove dir.deleteOnExit()) because directories may not be
removed reliably at JVM shutdown — ensure you reference
buildAttachmentPath(...), the local variables filename/file/dir, and the
createNewFile() logic when applying these changes.
🧹 Nitpick comments (1)
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java (1)
251-264: Platform-specific/tmpcheck and potential filename collisions.Two concerns with this helper:
Line 253: The
/tmpcheck is Unix-specific. On Windows, temp paths likeC:\Users\...\Tempwon't match, so the fallback toSystem.getProperty("java.io.tmpdir")won't trigger when it should.Line 263: Stripping all spaces from the path could cause filename collisions when two attachments differ only by spaces (e.g.,
"my file.pdf"and"myfile.pdf"would map to the same path).Consider a more robust approach:
Suggested improvement
private String buildAttachmentPath(String resourceId) { String basePath = prefixedPath; - if (basePath.startsWith("/tmp")) { + String systemTmp = System.getProperty("java.io.tmpdir"); + if (basePath.equals("/tmp") || basePath.equals(systemTmp)) { basePath = System.getProperty("java.io.tmpdir"); } StringBuilder path = new StringBuilder(basePath); if (!basePath.endsWith(File.separator)) { path.append(File.separator); } path.append("email_tmp").append(File.separator); path.append(resourceId.replace("\\", File.separator).replace("/", File.separator)); - return path.toString().replace(" ", ""); + return path.toString().trim(); }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java
📄 CodeRabbit inference engine (.cursor/rules/logging-rule.mdc)
**/*.java: Use SLF4J parameterized logging (logger.info("Value is: {}", value)) instead of string concatenation (logger.info("Value is: " + value))
Log messages and code comments should be in English. Log messages should never be translated.
**/*.java: Java: Never use local variable type inference (var). Always declare explicit types. Yes:Map<String, Integer> counts = new HashMap<>();No:var counts = new HashMap<String, Integer>();
When proposing Java code, spell out full types in local variable declarations,forloops, and try-with-resources
When editing Java, prefer clarity over brevity; avoid introducing language features that aren't widely used in the repo
Treat any PR or suggestion containing Javavaras non-compliant. Recommend replacing with explicit types before merge
**/*.java: Use Java 17 for trunk development (Java 11 was used for Sakai 22 and Sakai 23)
Do not use local variable type inference (var) in Java code. Always declare explicit types (e.g.,List<String> names = new ArrayList<>();notvar names = new ArrayList<String>();). Enforced by Checkstyle rule duringmvn validate
Files:
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java
🧠 Learnings (1)
📓 Common learnings
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR `#12312`, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR `#14154` (SAK-52058) restores visibility by checking only description.email.
Learnt from: CR
Repo: sakaiproject/sakai PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-07T16:11:33.008Z
Learning: Commit messages should follow: <issue key> <component> <brief description> (e.g., SAK-12345 Assignments add option x)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: sakai-deploy
- GitHub Check: maven-build
- GitHub Check: maven-build
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
https://sakaiproject.atlassian.net/browse/SAK-52133
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.