X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdatabase%2Fmemory%2FMemoryDatabase.java;h=d5d5396ce2c5a74e6c6d0e9d7c3f28292a8cc2f1;hb=f333f58180a7f112394cd768d86c95a3c9edf794;hp=7a548b9338c2a7c9870147da8a10569986d40802;hpb=551444095937c85ad3ae7009c0979c5f433036d3;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 7a548b9..d5d5396 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -275,7 +275,7 @@ public class MemoryDatabase extends AbstractService implements Database { /* if we’re still here, Sone was loaded successfully. */ lock.writeLock().lock(); try { - sone.setTime(soneTime); + updateSoneTime(sone, soneTime); sone.setProfile(profile); sone.setLikePostIds(likedPostIds); sone.setLikeReplyIds(likedReplyIds); @@ -464,6 +464,7 @@ public class MemoryDatabase extends AbstractService implements Database { @Override protected void doStart() { soneDatabase.start(); + memoryFriendDatabase.start(); postDatabase.start(); memoryBookmarkDatabase.start(); loadKnownPostReplies(); @@ -475,6 +476,7 @@ public class MemoryDatabase extends AbstractService implements Database { protected void doStop() { try { soneDatabase.stop(); + memoryFriendDatabase.stop(); postDatabase.stop(); memoryBookmarkDatabase.stop(); save(); @@ -515,6 +517,11 @@ public class MemoryDatabase extends AbstractService implements Database { soneDatabase.setSoneKnown(sone.getId()); } + @Override + public void updateSoneTime(Sone sone, long soneTime) { + soneDatabase.updateSoneTime(sone.getId(), soneTime); + } + private void storePosts(String soneId, Collection posts) { postDatabase.storePosts(soneId, posts); } @@ -624,7 +631,7 @@ public class MemoryDatabase extends AbstractService implements Database { } @Override - public Collection getFriends(Sone localSone) { + public Collection getFriends(LocalSone localSone) { if (!localSone.isLocal()) { return Collections.emptySet(); } @@ -632,7 +639,12 @@ public class MemoryDatabase extends AbstractService implements Database { } @Override - public boolean isFriend(Sone localSone, String friendSoneId) { + public Optional getSoneFollowingTime(String remoteSoneId) { + return memoryFriendDatabase.getSoneFollowingTime(remoteSoneId); + } + + @Override + public boolean isFriend(LocalSone localSone, String friendSoneId) { if (!localSone.isLocal()) { return false; } @@ -640,18 +652,12 @@ public class MemoryDatabase extends AbstractService implements Database { } @Override - public void addFriend(Sone localSone, String friendSoneId) { - if (!localSone.isLocal()) { - return; - } + public void addFriend(LocalSone localSone, String friendSoneId) { memoryFriendDatabase.addFriend(localSone.getId(), friendSoneId); } @Override - public void removeFriend(Sone localSone, String friendSoneId) { - if (!localSone.isLocal()) { - return; - } + public void removeFriend(LocalSone localSone, String friendSoneId) { memoryFriendDatabase.removeFriend(localSone.getId(), friendSoneId); }