This is an automated email from the ASF dual-hosted git repository.

aicam pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new d349c49e2d fix: improve email notification subject (#3729)
d349c49e2d is described below

commit d349c49e2dedb2248d2a53d9ac9962cf71724a6d
Author: Seongjin Yoon <[email protected]>
AuthorDate: Fri Sep 12 16:26:41 2025 -0700

    fix: improve email notification subject (#3729)
    
    **Description:**
    This PR fixes the previous implementation of enriching email subjects
    #3548 that aims to add the domain name in email subjects.
    
    **Problem:**
    The previous implementation used `ConfigFactory.load()` which reads from
    `application.conf` by default, but the `user-sys.domain` configuration
    is defined in `user-system.conf`, causing the domain retrieval to always
    fail and return empty strings.
    
    Documentation:
    
https://lightbend.github.io/config/latest/api/com/typesafe/config/ConfigFactory.html
    
    **Solution:**
    Replaced the incorrect domain retrieval with `UserSystemConfig` which
    properly reads from `user-system.conf`.
    
    Closes #3720
    
    **Email Subject Updates:**
    ```
    "New Account Request Pending Approval" -> "New Account Request Pending 
Approval for [server-name]"
    "Account Request Received"             -> "Account Request Received for 
[server-name]"
    "Your Role Has Been Updated"           -> "Your Role Has Been Updated for 
[server-name]"
    ```
    
    **Example:**
    <img width="1484" height="710" alt="Screenshot 2025-09-11 at 2 16 26 PM"
    
src="https://github.com/user-attachments/assets/21f4d9cd-8642-407c-914d-51c91d6858bd";
    />
    
    ---------
    
    Co-authored-by: Seongjin Yoon <[email protected]>
    Co-authored-by: Seongjin Yoon <[email protected]>
---
 .../ics/texera/web/resource/EmailTemplate.scala    | 27 +++++++---------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git 
a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/EmailTemplate.scala 
b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/EmailTemplate.scala
index be048c59e5..2879c8fc71 100644
--- 
a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/EmailTemplate.scala
+++ 
b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/EmailTemplate.scala
@@ -19,8 +19,8 @@
 
 package edu.uci.ics.texera.web.resource
 
-import com.typesafe.config.ConfigFactory
 import edu.uci.ics.texera.dao.jooq.generated.enums.UserRoleEnum
+import edu.uci.ics.texera.config.UserSystemConfig
 
 /**
   * EmailTemplate provides factory methods to generate email messages
@@ -28,13 +28,8 @@ import 
edu.uci.ics.texera.dao.jooq.generated.enums.UserRoleEnum
   */
 object EmailTemplate {
 
-  private val deployment: String = {
-    val config = ConfigFactory.load()
-    val rawDomain =
-      if (config.hasPath("user-sys.domain")) 
config.getString("user-sys.domain")
-      else ""
-    rawDomain.replaceFirst("^https?://", "")
-  }
+  private val deployment: String =
+    UserSystemConfig.appDomain.map(_.replaceFirst("^https?://", 
"")).getOrElse("")
 
   /**
     * Creates an email message for user registration notifications.
@@ -53,11 +48,8 @@ object EmailTemplate {
   ): EmailMessage = {
     if (toAdmin) {
       val subject =
-        if (deployment.nonEmpty)
-          s"New Account Request to $deployment Pending Approval"
-        else
-          "New Account Request Pending Approval"
-
+        s"New Account Request Pending Approval${if (deployment.nonEmpty) s" 
for [$deployment]"
+        else ""}"
       val content =
         s"""
            |Hello Admin,
@@ -73,7 +65,8 @@ object EmailTemplate {
            |""".stripMargin
       EmailMessage(subject = subject, content = content, receiver = 
receiverEmail)
     } else {
-      val subject = "Account Request Received"
+      val subject =
+        s"Account Request Received${if (deployment.nonEmpty) s" for 
[$deployment]" else ""}"
       val content =
         s"""
            |Hello,
@@ -98,11 +91,7 @@ object EmailTemplate {
     */
   def createRoleChangeTemplate(receiverEmail: String, newRole: UserRoleEnum): 
EmailMessage = {
     val subject =
-      if (deployment.nonEmpty)
-        s"Your Role Has Been Updated on $deployment"
-      else
-        "Your Role Has Been Updated"
-
+      s"Your Role Has Been Updated${if (deployment.nonEmpty) s" for 
[$deployment]" else ""}"
     val content =
       s"""
          |Hello,

Reply via email to