X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Futil%2FNotary.java;h=33bf674e5317ababfa9acc7a9fc9627d8d11e05a;hb=c3feb67ae28e66765dfcd2e7d50ddbceb64d92db;hp=2e6edd66524f4c16e471c163b2ea1b5cc3a7b423;hpb=0b0db3d1f59e3473fad2d8011f75552b7de1671e;p=gigi.git diff --git a/src/org/cacert/gigi/util/Notary.java b/src/org/cacert/gigi/util/Notary.java index 2e6edd66..33bf674e 100644 --- a/src/org/cacert/gigi/util/Notary.java +++ b/src/org/cacert/gigi/util/Notary.java @@ -48,16 +48,18 @@ public class Notary { try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `notary` where `to`=? and `from`=? and `method` = ? ::`notaryType` AND `deleted` IS NULL AND `when` > (now() - interval '1 days' * ?)")) { ps.setInt(1, target.getId()); ps.setInt(2, assurer.getId()); - ps.setString(3, AssuranceType.FACE_TO_FACE.getDescription()); + ps.setEnum(3, AssuranceType.FACE_TO_FACE); ps.setInt(4, LIMIT_DAYS_VERIFICATION); GigiResultSet rs = ps.executeQuery(); return !rs.next(); } } - public static final Group ASSURER_BLOCKED = Group.getByString("blockedassurer"); + public static final Group ASSURER_BLOCKED = Group.BLOCKEDASSURER; - public static final Group ASSUREE_BLOCKED = Group.getByString("blockedassuree"); + public static final Group ASSUREE_BLOCKED = Group.BLOCKEDASSUREE; + + public static final Group VERIFY_NOTIFICATION = Group.VERIFY_NOTIFICATION; /** * 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); + 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 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 mailVars = new HashMap<>(); mailVars.put("agent", assurer.getPreferredName().toString()); @@ -299,4 +306,27 @@ public class Notary { e.printStackTrace(); } } + + private static void sendVerificationNotificationAgent(User agent, User applicant, Name[] toVerify, final int awarded, String location, String date, Country country) { + HashMap 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(toVerify) { + + @Override + public void apply(Name t, Language l, Map vars) { + vars.put("name", t.toString()); + } + + }); + + try { + verificationAgentEntered.sendMail(Language.getInstance(applicant.getPreferredLocale()), mailVars, agent.getEmail()); + } catch (IOException e) { + e.printStackTrace(); + } + } }