Selaa lähdekoodia

only delete PUBLIC empty notes

Daniel Bohry 1 viikko sitten
vanhempi
sitoutus
d635ece021

+ 1 - 1
src/main/java/com/lhamacorp/knotes/repository/NoteRepository.java

@@ -14,7 +14,7 @@ public interface NoteRepository extends MongoRepository<Note, String> {
     @Query(value = "{ '_id': ?0 }", fields = "{ 'createdAt': 1, 'modifiedAt': 1 }")
     Optional<Note> findMetadataById(String id);
 
-    @Query(value = "{ 'content': BinData(0, '') }", fields = "{ '_id': 1, 'createdAt': 1 }")
+    @Query(value = "{ 'content': BinData(0, ''), 'encryptionMode': 'PUBLIC' }", fields = "{ '_id': 1, 'createdAt': 1 }")
     List<Note> findEmptyNotes();
 
     List<Note> findAllByCreatedBy(String createdBy);

+ 4 - 4
src/main/java/com/lhamacorp/knotes/service/CleanupScheduler.java

@@ -27,10 +27,10 @@ public class CleanupScheduler {
     @Scheduled(cron = ONCE_PER_DAY_AT_2AM)
     public void cleanup() {
         List<String> ids = repository.findEmptyNotes()
-            .stream()
-            .filter(note -> note.createdAt().isBefore(now().minus(1, DAYS)))
-            .map(Note::id)
-            .toList();
+                .stream()
+                .filter(note -> note.createdAt().isBefore(now().minus(1, DAYS)))
+                .map(Note::id)
+                .toList();
 
         if (!ids.isEmpty()) {
             log.info("Cleaning empty notes [{}]", ids);