]> WPIA git - gigi.git/commitdiff
add: implement opt-in for notification of RA Agent
authorINOPIAE <m.maengel@inopiae.de>
Fri, 19 Aug 2016 13:22:27 +0000 (15:22 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 8 Sep 2016 04:47:28 +0000 (06:47 +0200)
Sets the opt-in value for an RA Agent to receive a notification for
every Verification he enters and sends notification if value is given.

fixes issue #95

Change-Id: I4a544712831aa45b9b5ec252c79834c1f10fb179

src/org/cacert/gigi/database/DatabaseConnection.java
src/org/cacert/gigi/database/tableStructure.sql
src/org/cacert/gigi/database/upgrade/from_23.sql [new file with mode: 0644]
src/org/cacert/gigi/dbObjects/Group.java
src/org/cacert/gigi/util/Notary.java
src/org/cacert/gigi/util/VerificationAgentEntered.templ [new file with mode: 0644]

index b5684edd8bf8d4b0db46b2cbe500df7327ce1d2f..c22fc49af5c805b6d5f46a5e506f2c2df13f5327 100644 (file)
@@ -122,7 +122,7 @@ public class DatabaseConnection {
 
     }
 
 
     }
 
-    public static final int CURRENT_SCHEMA_VERSION = 23;
+    public static final int CURRENT_SCHEMA_VERSION = 24;
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
index 947b09edac5f4c4378f47a1a522593c760855537..7fbded1bfba2ee2675621aa1523eb1a4d4ae7f44 100644 (file)
@@ -327,7 +327,7 @@ CREATE TABLE IF NOT EXISTS "arbitrations" (
 DROP TABLE IF EXISTS "user_groups";
 
 DROP TYPE IF EXISTS "userGroup";
 DROP TABLE IF EXISTS "user_groups";
 
 DROP TYPE IF EXISTS "userGroup";
-CREATE TYPE "userGroup" AS enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning', 'orgassurer', 'blockedcert', 'nucleus-assurer', 'locate-agent');
+CREATE TYPE "userGroup" AS enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning', 'orgassurer', 'blockedcert', 'nucleus-assurer', 'locate-agent', 'verify-notification');
 
 CREATE TABLE IF NOT EXISTS "user_groups" (
   "id" serial NOT NULL,
 
 CREATE TABLE IF NOT EXISTS "user_groups" (
   "id" serial NOT NULL,
@@ -374,7 +374,7 @@ CREATE TABLE "schemeVersion" (
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
-INSERT INTO "schemeVersion" (version)  VALUES(23);
+INSERT INTO "schemeVersion" (version)  VALUES(24);
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
diff --git a/src/org/cacert/gigi/database/upgrade/from_23.sql b/src/org/cacert/gigi/database/upgrade/from_23.sql
new file mode 100644 (file)
index 0000000..1f41b04
--- /dev/null
@@ -0,0 +1 @@
+ALTER TYPE "userGroup" ADD VALUE 'verify-notification';
index d5dae430d68f6d3fa778a536f75c9eaba42c39d5..91becaf8c84d97b518810f3281f6cd08d9b066e4 100644 (file)
@@ -18,7 +18,8 @@ public enum Group implements DBEnum {
     CODESIGNING("codesigning", "may issue codesigning certificates", true, false, false), //
     ORGASSURER("orgassurer", "may verify organisations", true, false, true), //
     NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications", true, false, true), //
     CODESIGNING("codesigning", "may issue codesigning certificates", true, false, false), //
     ORGASSURER("orgassurer", "may verify organisations", true, false, true), //
     NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications", true, false, true), //
-    LOCATE_AGENT("locate-agent", "wants access to the locate agent system", false, true, false);
+    LOCATE_AGENT("locate-agent", "wants access to the locate agent system", false, true, false), //
+    VERIFY_NOTIFICATION("verify-notification", "wants to receive an email notification for any Verification they enter", false, true, false);
 
     private final String dbName;
 
 
     private final String dbName;
 
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();
+        }
+    }
 }
 }
diff --git a/src/org/cacert/gigi/util/VerificationAgentEntered.templ b/src/org/cacert/gigi/util/VerificationAgentEntered.templ
new file mode 100644 (file)
index 0000000..b66e38c
--- /dev/null
@@ -0,0 +1,12 @@
+Subject: <?=_Verification entered by you?>
+
+<?=_Hi?>,
+
+<?=_You entered a verification for the account with email address ${email}.?>
+<?=_You granted ${points} Verification Points to the following verified name(s):?>
+
+<? foreach($names) { ?>\
+<?=_${name}?>
+<? } ?>\
+
+<?=_You meet the Applicant on ${date} at ${location}, ${country}.?>