Repository: CSCfi/rems
Pull request #1612 (2019-09-11 07:31:19)

Improve email texts
for #1366 

# Definition of Done / Review checklist

## Reviewability
- [x] link to issue

## Documentation
- [x] update changelog if necessary

## Different installations
- [ ] new configuration options added to rems-deploy repository
- [ ] instance specific translations (i.e. LBR kielivara)

## Testing
- [x] complex logic is unit tested

## Follow-up
- [x] new tasks are created for pending or remaining tasks #1611



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df70d09fb..b9987f67f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -71,6 +71,7 @@ Changes since v2.4
 - Improved table performance: added a "show all rows" button for long tables
 - Modal popups have been replaced with flash messages (#1469)
 - Email messages now use the application title and full names of users
+- Email message texts improved
 
 ### Fixes
 - Entitlement API
diff --git a/resources/translations/en.edn b/resources/translations/en.edn
index 151df516d..d1d284df5 100644
--- a/resources/translations/en.edn
+++ b/resources/translations/en.edn
@@ -218,36 +218,43 @@
                     :title "Title"}
   :dropdown {:no-results "No results"
              :placeholder "Select..."}
-  :email {:application-approved {:subject "Application approved (%3)"
-                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been approved.\n\nView application: %6"
-                                 :message-to-handler "Dear %1,\n\n%2 has approved the application %3 from %4.\n\nView application: %6"}
-          :application-rejected {:subject "Application rejected (%3)"
-                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been rejected.\n\nView application: %6"
-                                 :message-to-handler "Dear %1,\n\n%2 has rejected the application %3 from %4.\n\nView application: %6"}
-          :application-closed {:subject "Application closed (%3)"
-                               :message-to-applicant "Dear %1,\n\nYour application %3 has been closed.\n\nView application: %6"
-                               :message-to-handler "Dear %1,\n\n%2 has closed the application %3 from %4.\n\nView application: %6"}
-          :application-returned {:subject "Application returned (%3)"
-                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been returned.\n\nView application: %6"
-                                 :message-to-handler "Dear %1,\n\n%2 has returned the application %3 from %4.\n\nView application: %6"}
-          :application-licenses-added {:subject "Terms of use added to application (%3)"
-                                       :message-to-applicant "Dear %1,\n\nTerms of use have been added to your application %3. They need to be accepted before gaining access to the resources.\n\nView application: %6"
-                                       :message-to-handler "Dear %1,\n\n%2 has added terms of use to the application %3 from %4.\n\nView application: %6"}
-          :application-submitted {:subject "Application submitted (%4: %3)"
-                                  :message "Dear %1,\n\n%4 has submitted an application (%3): %5.\n\nView application: %6"}
-          :comment-requested {:subject "Review requested (%2: %3)"
-                              :message "Dear %1,\n\n%2 has requested a review on application %3.\n\nComment: %6"}
-          :commented {:subject "Review added (%2: %3)"
-                      :message "Dear %1,\n\n%2 has reviewed application %3.\n\nView application: %6"}
-          :decided {:subject "Decision made (%2: %3)"
-                    :message "Dear %1,\n\n%2 has made a decision on application %3.\n\nView application: %6"}
-          :decision-requested {:subject "Decision requested (%2: %3)"
-                               :message "Dear %1,\n\n%2 has requested your decision on application %3.\n\nView application: %6"}
-          :footer "\n\nPlease don't reply to this automatically generated message."
+  :email {:application-approved {:subject-to-applicant "Your application has been approved (%3)"
+                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been approved.\n\nYou can view the application and the decision: %6"
+                                 :subject-to-handler "Application approved (%3)"
+                                 :message-to-handler "Dear %1,\n\n%2 has approved the application %3 from %4.\n\nYou can view the application and the decision: %6"}
+          :application-rejected {:subject-to-applicant "Your application has been rejected (%3)"
+                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been rejected.\n\nYou can view the application and the decision: %6"
+                                 :subject-to-handler "Application rejected (%3)"
+                                 :message-to-handler "Dear %1,\n\n%2 has rejected the application %3 from %4.\n\nYou can view the application and the decision: %6"}
+          :application-closed {:subject-to-applicant "Your application has been closed (%3)"
+                               :message-to-applicant "Dear %1,\n\nYour application %3 has been closed.\n\nYou can view the application: %6"
+                               :subject-to-handler "Application closed (%3)"
+                               :message-to-handler "Dear %1,\n\n%2 has closed the application %3 from %4.\n\nYou can view the application: %6"}
+          :application-returned {:subject-to-applicant "Your application has been returned for modifications (%3)"
+                                 :message-to-applicant "Dear %1,\n\nYour application %3 has been returned to you for modifications.\n\nYou can modify and resubmit the application: %6"
+                                 :subject-to-handler "Application has been returned for modifications (%3)"
+                                 :message-to-handler "Dear %1,\n\n%2 has returned the application %3 to the applicant %4 for modifications.\n\nYou can view the application: %6"}
+          :application-licenses-added {:subject "New terms of use waiting for approval (%3)"
+                                       :message "Dear %1,\n\n%2 has requested your acceptance for new terms of use for application %3.\n\nYou can view the application and accept the terms of use: %6"}
+          :application-resubmitted {:subject "Application has been resubmitted (%3)"
+                                    :message "Dear %1,\n\nApplication %3 has been resubmitted by %4.\n\nYou can view the application: %6"}
+          :application-submitted {:subject "A new application has been submitted (%3)"
+                                  :message "Dear %1,\n\n%4 has submitted a new application %3 to access resource(s) %5.\n\nYou can view the application: %6"}
+          :comment-requested {:subject "Review request (%3)"
+                              :message "Dear %1,\n\n%2 has requested your review on application %3 submitted by %4.\n\nYou can review the application: %6"}
+          :commented {:subject "Application has been reviewed (%3)"
+                     :message "Dear %1,\n\n%2 has reviewed the application %3 submitted by %4.\n\nYou can view the application and the review: %6"}
+          :decided {:subject "Decision notification (%3)"
+                    :message "Dear %1,\n\n%2 has sent a decision on application %3 submitted by %4.\n\nYou can view the application and the decision: %6"}
+          :decision-requested {:subject "Decision requested (%3)"
+                               :message "Dear %1,\n\n%2 has requested your decision on application %3 submitted by %4.\n\nYou can view application: %6"}
+          :footer "\n\nPlease do not reply to this automatically generated message."
           :member-added {:subject "Added as a member of an application (%3)"
                          :message "Dear %1,\n\nYou've been added as a member of application %3.\n\nView application: %6"}
           :member-invited {:subject "Invitation to participate in an application"
-                           :message "Hello,\n\nThis email address (%1) has been invited to participate in an application.\n\nParticipate: %2"}}
+                           :message "Dear %1,\n\nYou have been invited to participate in an application submitted by %2. The title of the application is %3.\n\nYou can view the application and accept the terms of use: %4"}
+          :remarked {:subject "Application has been commented on (%3)"
+                     :message "Dear %1,\n\n%2 has commented on the application %3 submitted by %4.\n\nYou can view the application and the comment: %6"}}
   :footer "CSC – IT Center for Science"
   :form {:accepted-licenses "Accepted terms of use"
          :actions "Actions"
diff --git a/resources/translations/fi.edn b/resources/translations/fi.edn
index efa342b51..cf7b6aeef 100644
--- a/resources/translations/fi.edn
+++ b/resources/translations/fi.edn
@@ -216,36 +216,43 @@
                     :title "Työvuon nimi"}
   :dropdown {:no-results "Ei tuloksia"
              :placeholder "Valitse..."}
-  :email {:application-approved {:subject "Hakemus hyväksytty (%3)"
-                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on hyväksytty.\n\nTarkastele hakemusta: %5"
-                                 :message-to-handler "Hyvä %1,\n\n%2 on hyväksynyt käyttäjän %4 hakemuksen %3.\n\nTarkastele hakemusta: %5"}
-          :application-rejected {:subject "Hakemus hylätty (%3)"
-                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on hylätty.\n\nTarkastele hakemusta: %5"
-                                 :message-to-handler "Hyvä %1,\n\n%2 on hylännyt käyttäjän %4 hakemuksen %3.\n\nTarkastele hakemusta: %5"}
-          :application-closed {:subject "Hakemus suljettu (%3)"
-                               :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on suljettu.\n\nTarkastele hakemusta: %5"
-                               :message-to-handler "Hyvä %1,\n\n%2 on sulkenut käyttäjän %4 hakemuksen %3.\n\nTarkastele hakemusta: %5"}
-          :application-returned {:subject "Hakemus palautettu (%3)"
-                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on palautettu.\n\nTarkastele hakemusta: %5"
-                                 :message-to-handler "Hyvä %1,\n\n%2 on palauttanut käyttäjän %4 hakemuksen %3.\n\nTarkastele hakemusta: %5"}
+  :email {:application-approved {:subject-to-applicant "Hakemuksesi on hyväksytty (%3)"
+                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on hyväksytty.\n\nVoit tarkastella hakemusta ja päätöstä: %6"
+                                 :subject-to-handler "Hakemus hyväksytty (%3)"
+                                 :message-to-handler "Hyvä %1,\n\n%2 on hyväksynyt käyttäjän %4 hakemuksen %3.\n\nVoit tarkastella hakemusta ja päätöstä: %6"}
+          :application-rejected {:subject-to-applicant "Hakemuksesi on hylätty (%3)"
+                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on hylätty.\n\nVoit tarkastella hakemusta ja päätöstä: %6"
+                                 :subject-to-handler "Hakemus hylätty (%3)"
+                                 :message-to-handler "Hyvä %1,\n\n%2 on hylännyt käyttäjän %4 hakemuksen %3.\n\nVoit tarkastella hakemusta ja päätöstä: %6"}
+          :application-closed {:subject-to-applicant "Hakemuksesi on suljettu (%3)"
+                               :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on suljettu.\n\nVoit tarkastella hakemusta: %5"
+                               :subject-to-handler "Hakemus suljettu (%3)"
+                               :message-to-handler "Hyvä %1,\n\n%2 on sulkenut käyttäjän %4 hakemuksen %3.\n\nVoit tarkastella hakemusta: %5"}
+          :application-returned {:subject-to-applicant "Hakemuksesi on palautettu (%3)"
+                                 :message-to-applicant "Hyvä %1,\n\nHakemuksesi %3 on palautettu muokattavaksi.\n\nVoit muokata hakemusta ja lähettää sen uudelleen: %6"
+                                 :subject-to-handler "Hakemus palautettu (%3)"
+                                 :message-to-handler "Hyvä %1,\n\n%2 on palauttanut käyttäjän %4 hakemuksen %3.\n\nVoit tarkastella hakemusta: %6"}
           :application-licenses-added {:subject "Hakemukseen lisätty käyttöehtoja (%3)"
-                                       :message-to-applicant "Hyvä %1,\n\nHakemukseesi %3 on lisätty käyttöehtoja. Käyttöehdot täytyy hyväksyä ennen käyttöoikeuden saamista.\n\nTarkastele hakemusta: %5"
-                                       :message-to-handler "Hyvä %1,\n\n%2 on lisännyt käyttöehtoja käyttäjän %4 hakemukseen %3.\n\nTarkastele hakemusta: %5"}
-          :application-submitted {:subject "Hakemus lähetetty (%4: %3)"
-                                  :message "Hyvä %1,\n\n%4 on lähettänyt käyttöoikeushakemuksen (%3): %5.\n\nTarkastele hakemusta: %6"}
-          :comment-requested {:subject "Katselmointipyyntö (%2: %3)"
-                              :message "Hyvä %1,\n\n%2 on pyytänyt katselmoimaan hakemuksen %3.\n\nKommentoi: %6"}
-          :commented {:subject "Hakemus katselmoitu (%2: %3)"
-                      :message "Hyvä %1,\n\n%2 on katselmoinut hakemuksen %3.\n\nTarkastele hakemusta: %6"}
-          :decided {:subject "Päätös tehty (%2: %3)"
-                    :message "Hyvä %1,\n\n%2 on tehnyt päätöksen hakemuksesta %3.\n\nTarkastele hakemusta: %6"}
-          :decision-requested {:subject "Päätöspyyntö (%2: %3)"
-                               :message "Hyvä %1,\n\n%2 on pyytänyt sinua tekemään päätöksen hakemuksesta %3.\n\nTarkastele hakemusta: %6"}
+                                       :message "Hyvä %1,\n\n%2 pyytää hyväksyntääsi uusille käyttöehdoille hakemukseen %3.\n\nVoit tarkastella hakemusta ja hyväksyä käyttöehdot: %6"}
+          :application-resubmitted {:subject "Hakemus lähetetty uudelleen (%3)"
+                                    :message "Dear %1,\n\nKäyttäjä %4 on lähettänyt uudelleen hakemuksen %3.\n\nVoit tarkastella hakemusta: %6"}
+          :application-submitted {:subject "Uusi hakemus (%3)"
+                                  :message "Hyvä %1,\n\n%4 on lähettänyt käyttöoikeushakemuksen %3 resurss(e)ille %5.\n\nVoit tarkastella hakemusta: %6"}
+          :comment-requested {:subject "Katselmointipyyntö (%3)"
+                              :message "Hyvä %1,\n\n%2 on pyytänyt katselmointiasi käyttäjän %4 lähettämälle hakemukselle %3.\n\nVoit katselmoida hakemuksen: %6"}
+          :commented {:subject "Hakemus katselmoitu (%3)"
+                      :message "Hyvä %1,\n\n%2 on katselmoinut käyttäjän %4 lähettämän hakemuksen %3.\n\nVoit tarkastella hakemusta ja lukea kommentit: %6"}
+          :decided {:subject "Päätös lähetetty (%3)"
+                    :message "Hyvä %1,\n\n%2 on lähettänyt päätöksen käyttäjän %4 hakemuksesta %3.\n\nVoit tarkastella hakemusta ja päätöstä: %6"}
+          :decision-requested {:subject "Päätöspyyntö (%3)"
+                               :message "Hyvä %1,\n\n%2 on pyytänyt sinulta päätöstä käyttäjän %4 hakemuksesta %3.\n\nVoit tarkastella hakemusta: %6"}
           :footer "\n\nTämä on automaattinen viesti. Älä vastaa."
           :member-added {:subject "Lisätty hakemuksen jäseneksi (%3)"
-                         :message "Hyvä %1,\n\nSinut on lisätty hakemuksen %3 jäseneksi.\n\nTarkastele hakemusta: %6"}
+                         :message "Hyvä %1,\n\nSinut on lisätty hakemuksen %3 jäseneksi.\n\nVoit tarkastella hakemusta: %6"}
           :member-invited {:subject "Kutsu osallistumaan hakemukseen"
-                           :message "Hei,\n\nTämä sähköpostiosoite (%1) on kutsuttu osallistumaan resurssien käyttöoikeushakemukseen.\n\nOsallistumislinkki: %2"}}
+                           :message "Hyvä %1,\n\nSinut on kutsuttu osallistumaan käyttäjän %2 jättämään käyttöoikeushakemukseen. Hakemuksen otsikko on %3.\n\nVoit tarkastella hakemusta ja hyväksyä käyttöehdot: %4"}
+          :remarked {:subject "Hakemusta kommentoitu (%3)"
+                     :message "Hyvä %1,\n\n%2 on kommentoinut käyttäjän %4 lähettämää hakemusta %3.\n\nVoit tarkastella hakemusta ja lukea kommentin: %6"}}
   :footer "CSC – Tieteen tietotekniikan keskus"
   :form {:accepted-licenses "Käyttöehdot hyväksytty"
          :actions "Toiminnot"
diff --git a/src/clj/rems/poller/email.clj b/src/clj/rems/poller/email.clj
index 7f9851e30..e60c8122c 100644
--- a/src/clj/rems/poller/email.clj
+++ b/src/clj/rems/poller/email.clj
@@ -95,58 +95,60 @@
 (defmethod event-to-emails-impl :application.event/approved [event application]
   (concat (emails-to-recipients (applicant-and-members application)
                                 event application
-                                :t.email.application-approved/subject
+                                :t.email.application-approved/subject-to-applicant
                                 :t.email.application-approved/message-to-applicant)
           (emails-to-recipients (other-handlers event application)
                                 event application
-                                :t.email.application-approved/subject
+                                :t.email.application-approved/subject-to-handler
                                 :t.email.application-approved/message-to-handler)))
 
 (defmethod event-to-emails-impl :application.event/rejected [event application]
   (concat (emails-to-recipients (applicant-and-members application)
                                 event application
-                                :t.email.application-rejected/subject
+                                :t.email.application-rejected/subject-to-applicant
                                 :t.email.application-rejected/message-to-applicant)
           (emails-to-recipients (other-handlers event application)
                                 event application
-                                :t.email.application-rejected/subject
+                                :t.email.application-rejected/subject-to-handler
                                 :t.email.application-rejected/message-to-handler)))
 
 (defmethod event-to-emails-impl :application.event/closed [event application]
   (concat (emails-to-recipients (applicant-and-members application)
                                 event application
-                                :t.email.application-closed/subject
+                                :t.email.application-closed/subject-to-applicant
                                 :t.email.application-closed/message-to-applicant)
           (emails-to-recipients (other-handlers event application)
                                 event application
-                                :t.email.application-closed/subject
+                                :t.email.application-closed/subject-to-handler
                                 :t.email.application-closed/message-to-handler)))
 
 (defmethod event-to-emails-impl :application.event/returned [event application]
   (concat (emails-to-recipients (applicant-and-members application)
                                 event application
-                                :t.email.application-returned/subject
+                                :t.email.application-returned/subject-to-applicant
                                 :t.email.application-returned/message-to-applicant)
           (emails-to-recipients (other-handlers event application)
                                 event application
-                                :t.email.application-returned/subject
+                                :t.email.application-returned/subject-to-handler
                                 :t.email.application-returned/message-to-handler)))
 
 (defmethod event-to-emails-impl :application.event/licenses-added [event application]
-  (concat (emails-to-recipients (applicant-and-members application)
-                                event application
-                                :t.email.application-licenses-added/subject
-                                :t.email.application-licenses-added/message-to-applicant)
-          (emails-to-recipients (other-handlers event application)
-                                event application
-                                :t.email.application-licenses-added/subject
-                                :t.email.application-licenses-added/message-to-handler)))
+  (emails-to-recipients (applicant-and-members application)
+                        event application
+                        :t.email.application-licenses-added/subject
+                        :t.email.application-licenses-added/message))
 
 (defmethod event-to-emails-impl :application.event/submitted [event application]
-  (emails-to-recipients (handlers application)
-                        event application
-                        :t.email.application-submitted/subject
-                        :t.email.application-submitted/message))
+  (if (= (:event/time event)
+         (:application/first-submitted application))
+    (emails-to-recipients (handlers application)
+                          event application
+                          :t.email.application-submitted/subject
+                          :t.email.application-submitted/message)
+    (emails-to-recipients (handlers application)
+                          event application
+                          :t.email.application-resubmitted/subject
+                          :t.email.application-resubmitted/message)))
 
 (defmethod event-to-emails-impl :application.event/comment-requested [event application]
   (emails-to-recipients (:application/commenters event)
@@ -160,6 +162,12 @@
                         :t.email.commented/subject
                         :t.email.commented/message))
 
+(defmethod event-to-emails-impl :application.event/remarked [event application]
+  (emails-to-recipients (handlers application)
+                        event application
+                        :t.email.remarked/subject
+                        :t.email.remarked/message))
+
 (defmethod event-to-emails-impl :application.event/decided [event application]
   (emails-to-recipients (handlers application)
                         event application
@@ -179,16 +187,16 @@
                         :t.email.member-added/subject
                         :t.email.member-added/message))
 
-(defmethod event-to-emails-impl :application.event/member-invited [event _application]
+(defmethod event-to-emails-impl :application.event/member-invited [event application]
   (with-language (:default-language env)
     (fn []
       [{:to (:email (:application/member event))
-        :subject (text-format :t.email.member-invited/subject
-                              (:email (:application/member event))
-                              (invitation-link (:invitation/token event)))
+        :subject (text-format :t.email.member-invited/subject)
         :body (str
                (text-format :t.email.member-invited/message
-                            (:email (:application/member event))
+                            (:name (:application/member event))
+                            (user-for-email (:application/applicant application))
+                            (format-application-for-email application)
                             (invitation-link (:invitation/token event)))
                (text :t.email/footer))}])))
 


Test patch:
diff --git a/test/clj/rems/poller/test_email.clj b/test/clj/rems/poller/test_email.clj
index 8716f2829..daa6ad993 100644
--- a/test/clj/rems/poller/test_email.clj
+++ b/test/clj/rems/poller/test_email.clj
@@ -67,6 +67,11 @@
                               :field/optional false
                               :field/type :description}]}))
 
+(def ^:private get-license
+  (constantly {:id 1234
+               :licensetype "text"
+               :textcontent "foobar"}))
+
 (defn ^:private get-nothing [& _]
   nil)
 
@@ -81,7 +86,7 @@
                         (model/enrich-with-injections {:get-workflow get-workflow
                                                        :get-catalogue-item get-catalogue-item
                                                        :get-form-template get-form-template
-                                                       :get-license get-nothing
+                                                       :get-license get-license
                                                        :get-user get-nothing
                                                        :get-users-with-role get-nothing
                                                        :get-attachments-for-application get-nothing}))]
@@ -106,7 +111,8 @@
                       :application/field-values {1 "Application title"}}
                      {:application/id 7
                       :event/type :application.event/submitted
-                      :event/actor "applicant"}]]
+                      :event/actor "applicant"
+                      :event/time 13}]]
     (let [events (into
                   base-events
                   [{:application/id 7
@@ -126,11 +132,19 @@
                     :event/type :application.event/commented
                     :event/actor "commenter2"
                     :application/request-id "r1"
-                    :application/comment ["this is a comment"]}
+                    :application/comment "this is a comment"}
+                   {:application/id 7
+                    :event/type :application.event/remarked
+                    :event/actor "remarker"
+                    :application/comment "remark!"}
                    {:application/id 7
                     :event/type :application.event/member-added
                     :event/actor "handler"
                     :application/member {:userid "member"}}
+                   {:application/id 7
+                    :event/type :application.event/licenses-added
+                    :event/actor "handler"
+                    :application/licenses [{:license/id 1234}]}
                    {:application/id 7
                     :event/type :application.event/decision-requested
                     :event/actor "assistant"
@@ -148,64 +162,79 @@
                     :event/actor "assistant"}])]
       (is (= [[]
               []
-              [{:to-user "assistant",
-                :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                :body "Dear assistant,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "handler",
-                :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+              [{:to-user "assistant"
+                :subject "A new application has been submitted (2001/3, \"Application title\")"
+                :body "Dear assistant,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "handler"
+                :subject "A new application has been submitted (2001/3, \"Application title\")"
+                :body "Dear Hannah Handler,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to "somebody@example.com",
                 :subject "Invitation to participate in an application",
-                :body "Hello,\n\nThis email address (somebody@example.com) has been invited to participate in an application.\n\nParticipate: http://example.com/accept-invitation?token=abc\n\nPlease don't reply to this automatically generated message."}]
-              [{:to-user "commenter1",
-                :subject "Review requested (Hannah Handler: 2001/3, \"Application title\")",
-                :body "Dear commenter1,\n\nHannah Handler has requested a review on application 2001/3, \"Application title\".\n\nComment: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "commenter2",
-                :subject "Review requested (Hannah Handler: 2001/3, \"Application title\")",
-                :body "Dear commenter2,\n\nHannah Handler has requested a review on application 2001/3, \"Application title\".\n\nComment: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+                :body "Dear Some Body,\n\nYou have been invited to participate in an application submitted by Alice Applicant. The title of the application is 2001/3, \"Application title\".\n\nYou can view the application and accept the terms of use: http://example.com/accept-invitation?token=abc\n\nPlease do not reply to this automatically generated message."}]
+              [{:to-user "commenter1"
+                :subject "Review request (2001/3, \"Application title\")"
+                :body "Dear commenter1,\n\nHannah Handler has requested your review on application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can review the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "commenter2"
+                :subject "Review request (2001/3, \"Application title\")"
+                :body "Dear commenter2,\n\nHannah Handler has requested your review on application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can review the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               []
-              [{:to-user "assistant",
-                :subject "Review added (commenter2: 2001/3, \"Application title\")",
-                :body "Dear assistant,\n\ncommenter2 has reviewed application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "handler",
-                :subject "Review added (commenter2: 2001/3, \"Application title\")",
-                :body "Dear Hannah Handler,\n\ncommenter2 has reviewed application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+              [{:to-user "assistant"
+                :subject "Application has been reviewed (2001/3, \"Application title\")"
+                :body "Dear assistant,\n\ncommenter2 has reviewed the application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the review: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "handler"
+                :subject "Application has been reviewed (2001/3, \"Application title\")"
+                :body "Dear Hannah Handler,\n\ncommenter2 has reviewed the application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the review: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
+              [{:to-user "assistant"
+                :subject "Application has been commented on (2001/3, \"Application title\")"
+                :body "Dear assistant,\n\nremarker has commented on the application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the comment: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "handler"
+                :subject "Application has been commented on (2001/3, \"Application title\")"
+                :body "Dear Hannah Handler,\n\nremarker has commented on the application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the comment: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to-user "member",
                 :subject "Added as a member of an application (2001/3, \"Application title\")",
-                :body "Dear member,\n\nYou've been added as a member of application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+                :body "Dear member,\n\nYou've been added as a member of application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
+              [{:to-user "applicant"
+                :subject "New terms of use waiting for approval (2001/3, \"Application title\")"
+                :body "Dear Alice Applicant,\n\nHannah Handler has requested your acceptance for new terms of use for application 2001/3, \"Application title\".\n\nYou can view the application and accept the terms of use: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "member"
+                :subject "New terms of use waiting for approval (2001/3, \"Application title\")"
+                :body "Dear member,\n\nHannah Handler has requested your acceptance for new terms of use for application 2001/3, \"Application title\".\n\nYou can view the application and accept the terms of use: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "somebody"
+                :subject "New terms of use waiting for approval (2001/3, \"Application title\")"
+                :body "Dear somebody,\n\nHannah Handler has requested your acceptance for new terms of use for application 2001/3, \"Application title\".\n\nYou can view the application and accept the terms of use: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to-user "decider",
-                :subject "Decision requested (assistant: 2001/3, \"Application title\")",
-                :body "Dear decider,\n\nassistant has requested your decision on application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+                :subject "Decision requested (2001/3, \"Application title\")",
+                :body "Dear decider,\n\nassistant has requested your decision on application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to-user "assistant",
-                :subject "Decision made (decider: 2001/3, \"Application title\")",
-                :body "Dear assistant,\n\ndecider has made a decision on application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
+                :subject "Decision notification (2001/3, \"Application title\")",
+                :body "Dear assistant,\n\ndecider has sent a decision on application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
                {:to-user "handler",
-                :subject "Decision made (decider: 2001/3, \"Application title\")",
-                :body "Dear Hannah Handler,\n\ndecider has made a decision on application 2001/3, \"Application title\".\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+                :subject "Decision notification (2001/3, \"Application title\")",
+                :body "Dear Hannah Handler,\n\ndecider has sent a decision on application 2001/3, \"Application title\" submitted by Alice Applicant.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to-user "applicant"
-                :subject "Application approved (2001/3, \"Application title\")",
-                :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
+                :subject "Your application has been approved (2001/3, \"Application title\")"
+                :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
                {:to-user "assistant"
                 :subject "Application approved (2001/3, \"Application title\")"
-                :body "Dear assistant,\n\nHannah Handler has approved the application 2001/3, \"Application title\" from Alice Applicant.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "member",
-                :subject "Application approved (2001/3, \"Application title\")",
-                :body "Dear member,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "somebody",
-                :subject "Application approved (2001/3, \"Application title\")",
-                :body "Dear somebody,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
+                :body "Dear assistant,\n\nHannah Handler has approved the application 2001/3, \"Application title\" from Alice Applicant.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "member"
+                :subject "Your application has been approved (2001/3, \"Application title\")"
+                :body "Dear member,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "somebody"
+                :subject "Your application has been approved (2001/3, \"Application title\")"
+                :body "Dear somebody,\n\nYour application 2001/3, \"Application title\" has been approved.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
               [{:to-user "applicant"
-                :subject "Application closed (2001/3, \"Application title\")",
-                :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
+                :subject "Your application has been closed (2001/3, \"Application title\")"
+                :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
                {:to-user "handler"
                 :subject "Application closed (2001/3, \"Application title\")"
-                :body "Dear Hannah Handler,\n\nassistant has closed the application 2001/3, \"Application title\" from Alice Applicant.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "member",
-                :subject "Application closed (2001/3, \"Application title\")",
-                :body "Dear member,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "somebody",
-                :subject "Application closed (2001/3, \"Application title\")",
-                :body "Dear somebody,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]]
+                :body "Dear Hannah Handler,\n\nassistant has closed the application 2001/3, \"Application title\" from Alice Applicant.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "member"
+                :subject "Your application has been closed (2001/3, \"Application title\")"
+                :body "Dear member,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "somebody"
+                :subject "Your application has been closed (2001/3, \"Application title\")"
+                :body "Dear somebody,\n\nYour application 2001/3, \"Application title\" has been closed.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]]
              (events-to-emails events))))
     (testing "application rejected"
       (let [events (conj base-events
@@ -214,38 +243,38 @@
                           :event/actor "handler"})]
         (is (= [[]
                 []
-                [{:to-user "assistant",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear assistant,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-                 {:to-user "handler",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
-                [{:subject "Application rejected (2001/3, \"Application title\")",
-                  :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been rejected.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message.",
-                  :to-user "applicant"}
-                 {:subject "Application rejected (2001/3, \"Application title\")"
-                  :body "Dear assistant,\n\nHannah Handler has rejected the application 2001/3, \"Application title\" from Alice Applicant.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."
-                  :to-user "assistant"}]]
+                [{:to-user "assistant"
+                  :subject "A new application has been submitted (2001/3, \"Application title\")"
+                  :body "Dear assistant,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+                 {:to-user "handler"
+                  :subject "A new application has been submitted (2001/3, \"Application title\")"
+                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
+                [{:to-user "applicant"
+                  :subject "Your application has been rejected (2001/3, \"Application title\")",
+                  :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been rejected.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+                 {:to-user "assistant"
+                  :subject "Application rejected (2001/3, \"Application title\")",
+                  :body "Dear assistant,\n\nHannah Handler has rejected the application 2001/3, \"Application title\" from Alice Applicant.\n\nYou can view the application and the decision: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]]
                (events-to-emails events)))))
     (testing "id field can be overrided"
       (with-redefs [rems.config/env (assoc rems.config/env :application-id-column :id)]
         (is (= [[]
                 []
                 [{:to-user "assistant"
-                  :subject "Application submitted (Alice Applicant: 7, \"Application title\")"
-                  :body "Dear assistant,\n\nAlice Applicant has submitted an application (7, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
+                  :subject "A new application has been submitted (7, \"Application title\")"
+                  :body "Dear assistant,\n\nAlice Applicant has submitted a new application 7, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
                  {:to-user "handler"
-                  :subject "Application submitted (Alice Applicant: 7, \"Application title\")"
-                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (7, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]]
+                  :subject "A new application has been submitted (7, \"Application title\")"
+                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted a new application 7, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]]
                (events-to-emails base-events)))))
     (testing "application title is optional"
       (is (= [[]
-              [{:to-user "assistant",
-                :subject "Application submitted (Alice Applicant: 2001/3)",
-                :body "Dear assistant,\n\nAlice Applicant has submitted an application (2001/3): en title 11.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-               {:to-user "handler",
-                :subject "Application submitted (Alice Applicant: 2001/3)",
-                :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (2001/3): en title 11.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]]
+              [{:to-user "assistant"
+                :subject "A new application has been submitted (2001/3)"
+                :body "Dear assistant,\n\nAlice Applicant has submitted a new application 2001/3 to access resource(s) en title 11.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+               {:to-user "handler"
+                :subject "A new application has been submitted (2001/3)"
+                :body "Dear Hannah Handler,\n\nAlice Applicant has submitted a new application 2001/3 to access resource(s) en title 11.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]]
              (events-to-emails [{:application/id 7
                                  :application/external-id "2001/3"
                                  :event/type :application.event/created
@@ -257,7 +286,7 @@
                                 {:application/id 7
                                  :event/type :application.event/submitted
                                  :event/actor "applicant"}]))))
-    (testing "returning application to applicant and re-submitting"
+    (testing "returning application to applicant and resubmitting"
       (let [events (conj base-events
                          {:application/id 7
                           :event/type :application.event/returned
@@ -268,22 +297,22 @@
                           :event/actor "applicant"})]
         (is (= [[]
                 []
-                [{:to-user "assistant",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear assistant,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-                 {:to-user "handler",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
-                [{:to-user "applicant",
-                  :subject "Application returned (2001/3, \"Application title\")",
-                  :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been returned.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-                 {:to-user "assistant",
-                  :subject "Application returned (2001/3, \"Application title\")",
-                  :body "Dear assistant,\n\nHannah Handler has returned the application 2001/3, \"Application title\" from Alice Applicant.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]
-                [{:to-user "assistant",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear assistant,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}
-                 {:to-user "handler",
-                  :subject "Application submitted (Alice Applicant: 2001/3, \"Application title\")",
-                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted an application (2001/3, \"Application title\"): en title 11, en title 21.\n\nView application: http://example.com/#/application/7\n\nPlease don't reply to this automatically generated message."}]]
+                [{:to-user "assistant"
+                  :subject "A new application has been submitted (2001/3, \"Application title\")"
+                  :body "Dear assistant,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+                 {:to-user "handler"
+                  :subject "A new application has been submitted (2001/3, \"Application title\")"
+                  :body "Dear Hannah Handler,\n\nAlice Applicant has submitted a new application 2001/3, \"Application title\" to access resource(s) en title 11, en title 21.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
+                [{:to-user "applicant"
+                  :subject "Your application has been returned for modifications (2001/3, \"Application title\")"
+                  :body "Dear Alice Applicant,\n\nYour application 2001/3, \"Application title\" has been returned to you for modifications.\n\nYou can modify and resubmit the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+                 {:to-user "assistant"
+                  :subject "Application has been returned for modifications (2001/3, \"Application title\")"
+                  :body "Dear assistant,\n\nHannah Handler has returned the application 2001/3, \"Application title\" to the applicant Alice Applicant for modifications.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]
+                [{:to-user "assistant"
+                  :subject "Application has been resubmitted (2001/3, \"Application title\")"
+                  :body "Dear assistant,\n\nApplication 2001/3, \"Application title\" has been resubmitted by Alice Applicant.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}
+                 {:to-user "handler"
+                  :subject "Application has been resubmitted (2001/3, \"Application title\")"
+                  :body "Dear Hannah Handler,\n\nApplication 2001/3, \"Application title\" has been resubmitted by Alice Applicant.\n\nYou can view the application: http://example.com/#/application/7\n\nPlease do not reply to this automatically generated message."}]]
                (events-to-emails events)))))))