]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/Notary.java
add: implement opt-in for notification of RA Agent
[gigi.git] / src / org / cacert / gigi / util / Notary.java
index e853bd62bd230690ce266191806c687b7d9ccab5..33bf674e5317ababfa9acc7a9fc9627d8d11e05a 100644 (file)
@@ -59,6 +59,8 @@ public class Notary {
 
     public static final Group ASSUREE_BLOCKED = Group.BLOCKEDASSUREE;
 
 
     public static final Group ASSUREE_BLOCKED = Group.BLOCKEDASSUREE;
 
+    public static final Group VERIFY_NOTIFICATION = Group.VERIFY_NOTIFICATION;
+
     /**
      * This method assures another user.
      * 
     /**
      * This method assures another user.
      * 
@@ -259,10 +261,15 @@ public class Notary {
             assure(assurer, assuree, toAssure[i], dob, awarded, location, date, type, country);
         }
         sendVerificationNotificationApplicant(assurer, assuree, toAssure, awarded, hadLessThan50Points, hadTotalLessThan100);
             assure(assurer, assuree, toAssure[i], dob, awarded, location, date, type, country);
         }
         sendVerificationNotificationApplicant(assurer, assuree, toAssure, awarded, hadLessThan50Points, hadTotalLessThan100);
+        if (assurer.isInGroup(VERIFY_NOTIFICATION)) {
+            sendVerificationNotificationAgent(assurer, assuree, toAssure, awarded, location, date, country);
+        }
     }
 
     private static final MailTemplate verificationEntered = new MailTemplate(Notary.class.getResource("VerificationEntered.templ"));
 
     }
 
     private static final MailTemplate verificationEntered = new MailTemplate(Notary.class.getResource("VerificationEntered.templ"));
 
+    private static final MailTemplate verificationAgentEntered = new MailTemplate(Notary.class.getResource("VerificationAgentEntered.templ"));
+
     private static void sendVerificationNotificationApplicant(User assurer, User assuree, Name[] toAssure, final int awarded, final boolean[] hadLessThan50Points, boolean hadTotalLessThan100) {
         HashMap<String, Object> mailVars = new HashMap<>();
         mailVars.put("agent", assurer.getPreferredName().toString());
     private static void sendVerificationNotificationApplicant(User assurer, User assuree, Name[] toAssure, final int awarded, final boolean[] hadLessThan50Points, boolean hadTotalLessThan100) {
         HashMap<String, Object> mailVars = new HashMap<>();
         mailVars.put("agent", assurer.getPreferredName().toString());
@@ -299,4 +306,27 @@ public class Notary {
             e.printStackTrace();
         }
     }
             e.printStackTrace();
         }
     }
+
+    private static void sendVerificationNotificationAgent(User agent, User applicant, Name[] toVerify, final int awarded, String location, String date, Country country) {
+        HashMap<String, Object> mailVars = new HashMap<>();
+        mailVars.put("email", applicant.getEmail());
+        mailVars.put("location", location);
+        mailVars.put("date", date);
+        mailVars.put("country", country.getName());
+        mailVars.put("points", Integer.toString(awarded));
+        mailVars.put("names", new ArrayIterable<Name>(toVerify) {
+
+            @Override
+            public void apply(Name t, Language l, Map<String, Object> vars) {
+                vars.put("name", t.toString());
+            }
+
+        });
+
+        try {
+            verificationAgentEntered.sendMail(Language.getInstance(applicant.getPreferredLocale()), mailVars, agent.getEmail());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }
 }