#1073 Add delay to email recovery command

- Add configurable cooldown period after sending an email for /email recovery
- Change ExpiringMap to remove expired entries (like ExpiringSet)
- Create method to translate durations via the messages file
This commit is contained in:
ljacqu
2017-02-25 22:41:49 +01:00
parent a4b440bcca
commit c197a330f3
11 changed files with 252 additions and 72 deletions
@@ -46,7 +46,13 @@ public class ExpiringMap<K, V> {
*/
public V get(K key) {
ExpiringEntry<V> value = entries.get(key);
return value == null ? null : value.getValue();
if (value == null) {
return null;
} else if (System.currentTimeMillis() > value.getExpiration()) {
entries.remove(key);
return null;
}
return value.getValue();
}
/**
@@ -115,7 +121,7 @@ public class ExpiringMap<K, V> {
}
V getValue() {
return System.currentTimeMillis() > expiration ? null : value;
return value;
}
long getExpiration() {