feat: add endpoint to trigger user follow updates
Some checks failed
ci/woodpecker/push/pipeline Pipeline was successful
ci/woodpecker/pr/pipeline Pipeline failed

This commit is contained in:
Rodrigo Verdiani 2025-11-12 21:56:33 -03:00
parent aab2f52938
commit 89bcd058b6
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.repository.UserRepository;
import com.magamochi.mangamochi.task.ImageCleanupTask;
import com.magamochi.mangamochi.task.MangaFollowUpdateTask;
import com.magamochi.mangamochi.task.UpdateMangaListTask;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
public class ManagementController {
private final UpdateMangaListTask updateMangaListTask;
private final ImageCleanupTask imageCleanupTask;
private final MangaFollowUpdateTask mangaFollowUpdateTask;
private final UserRepository userRepository;
private final NtfyClient ntfyClient;
@ -43,6 +45,18 @@ public class ManagementController {
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(
summary = "Test notification",
description = "Sends a test notification to all users",
@ -56,7 +70,7 @@ public class ManagementController {
user ->
ntfyClient.notify(
new NtfyClient.Request(
"mangamochi/" + user.getId().toString(),
"mangamochi-" + user.getId().toString(),
"Mangamochi",
"This is a test notification :)")));

View File

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