X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Futil%2FNotary.java;h=aa806fa929ce2b06ee4d4f31c5ce837213cddeae;hp=2f3a3aec56764dc520898aeea1b292ba91cf3b95;hb=0176ca7cda25ad88e9faa116ffa139ca926de273;hpb=d1080ab12183cad2bab5d1f94bafe67960fbf4c8 diff --git a/src/org/cacert/gigi/util/Notary.java b/src/org/cacert/gigi/util/Notary.java index 2f3a3aec..aa806fa9 100644 --- a/src/org/cacert/gigi/util/Notary.java +++ b/src/org/cacert/gigi/util/Notary.java @@ -129,6 +129,8 @@ public class Notary { if (type == AssuranceType.FACE_TO_FACE) { assureF2F(assurer, assuree, awarded, location, date); + } else if (type == AssuranceType.NUCLEUS) { + assureNucleus(assurer, assuree, awarded, location, date); } else if (type == AssuranceType.TTP_ASSISTED) { assureTTP(assurer, assuree, awarded, location, date); } else { @@ -189,4 +191,27 @@ public class Notary { } throw new GigiApiException("Assurance type not possible."); } + + private static void assureNucleus(User assurer, User assuree, int awarded, String location, String date) throws GigiApiException { + may(assurer, assuree, AssuranceType.NUCLEUS); + // Do up to 35 points as f2f + int f2fPoints = Math.min(35, awarded); + assureF2F(assurer, assuree, f2fPoints, location, date); + + awarded -= f2fPoints; + if (awarded <= 0) { + return; + } + + // Assure remaining points as "Nucleus Bonus" + // Valid for 4 Weeks = 28 days + try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `method`='Nucleus Bonus', `expire` = CURRENT_TIMESTAMP + interval '28 days'")) { + ps.setInt(1, assurer.getId()); + ps.setInt(2, assuree.getId()); + ps.setInt(3, awarded); + ps.setString(4, location); + ps.setString(5, date); + ps.execute(); + } + } }