feat: add endpoint to trigger user follow updates #18

Merged
rov merged 1 commits from feature/manga-follow into main 2025-11-12 22:07:51 -03:00
2 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import com.magamochi.mangamochi.client.NtfyClient;
import com.magamochi.mangamochi.model.dto.DefaultResponseDTO; import com.magamochi.mangamochi.model.dto.DefaultResponseDTO;
import com.magamochi.mangamochi.model.repository.UserRepository; import com.magamochi.mangamochi.model.repository.UserRepository;
import com.magamochi.mangamochi.task.ImageCleanupTask; import com.magamochi.mangamochi.task.ImageCleanupTask;
import com.magamochi.mangamochi.task.MangaFollowUpdateTask;
import com.magamochi.mangamochi.task.UpdateMangaListTask; import com.magamochi.mangamochi.task.UpdateMangaListTask;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
public class ManagementController { public class ManagementController {
private final UpdateMangaListTask updateMangaListTask; private final UpdateMangaListTask updateMangaListTask;
private final ImageCleanupTask imageCleanupTask; private final ImageCleanupTask imageCleanupTask;
private final MangaFollowUpdateTask mangaFollowUpdateTask;
private final UserRepository userRepository; private final UserRepository userRepository;
private final NtfyClient ntfyClient; private final NtfyClient ntfyClient;
@ -43,6 +45,18 @@ public class ManagementController {
return DefaultResponseDTO.ok().build(); return DefaultResponseDTO.ok().build();
} }
@Operation(
summary = "Trigger user follow update",
description = "Trigger user follow update",
tags = {"Management"},
operationId = "userFollowUpdate")
@PostMapping("user-follow")
public DefaultResponseDTO<Void> triggerUserFollowUpdate() {
mangaFollowUpdateTask.updateMangaList();
return DefaultResponseDTO.ok().build();
}
@Operation( @Operation(
summary = "Test notification", summary = "Test notification",
description = "Sends a test notification to all users", description = "Sends a test notification to all users",
@ -56,7 +70,7 @@ public class ManagementController {
user -> user ->
ntfyClient.notify( ntfyClient.notify(
new NtfyClient.Request( new NtfyClient.Request(
"mangamochi/" + user.getId().toString(), "mangamochi-" + user.getId().toString(),
"Mangamochi", "Mangamochi",
"This is a test notification :)"))); "This is a test notification :)")));

View File

@ -144,7 +144,7 @@ public class MangaService {
umf -> umf ->
ntfyClient.notify( ntfyClient.notify(
new NtfyClient.Request( new NtfyClient.Request(
"mangamochi/" + umf.getUser().getId().toString(), "mangamochi-" + umf.getUser().getId().toString(),
umf.getManga().getTitle(), umf.getManga().getTitle(),
"New chapter available on " + mangaProvider.getProvider().getName()))); "New chapter available on " + mangaProvider.getProvider().getName())));
} }