improved anonymization

This commit is contained in:
2024-06-11 20:35:23 +02:00
parent 2ca997fca9
commit c293f20559
3 changed files with 28 additions and 18 deletions

View File

@@ -35,21 +35,16 @@ public class JodelPost {
public Optional<Long> parent = Optional.empty();
// anonymize function to recursively anonymize the posts
public void anonymize(Optional<Vector<Long>> idCache) {
// check if this is the first post in this process
if (idCache.isEmpty()) {
// create a new Vector as cache
idCache = Optional.of(new Vector<>());
}
public void anonymize(Vector<Long> idCache) {
// get the anonymized id as index in cached authorIDs
int i = idCache.get().indexOf(this.authorID);
int i = idCache.indexOf(this.authorID);
// if the index is -1 the authorID has not been cached jet
if (i == -1) {
// set the current anonymousID as length of the cache (== next index)
this.anonymousID = (long) idCache.get().size();
this.anonymousID = (long) idCache.size();
// push the current authorID to to cache
idCache.get().add(this.authorID);
idCache.add(this.authorID);
}
// the authorID has been anonymized once before, so we can get it from cache
else this.anonymousID = (long) i;