- return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), User.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"));
+ try {
+ return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), Name.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"), res.getString("country") == null ? null : Country.getCountryByCode(res.getString("country"), CountryCodeType.CODE_2_CHARS));
+ } catch (GigiApiException e) {
+ throw new Error(e);
+ }
+ }
+
+ public boolean isInVerificationLimit() {
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `notary` INNER JOIN `names` ON `names`.`id`=`to` WHERE `names`.`uid` = ? AND `when` > (now() - (interval '1 month' * ?)) AND (`expire` IS NULL OR `expire` > now()) AND `notary`.`deleted` IS NULL;")) {
+ ps.setInt(1, getId());
+ ps.setInt(2, VERIFICATION_MONTHS);
+
+ GigiResultSet rs = ps.executeQuery();
+ return rs.next();
+ }
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {}
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {}
+
+ public Country getResidenceCountry() {
+ return residenceCountry;
+ }
+
+ public void setResidenceCountry(Country residenceCountry) {
+ this.residenceCountry = residenceCountry;
+ rawUpdateCountryData();
+ }
+
+ private void rawUpdateCountryData() {
+ try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET country=? WHERE id=?")) {
+ update.setString(1, residenceCountry == null ? null : residenceCountry.getCode());
+ update.setInt(2, getId());
+ update.executeUpdate();
+ }