Skip to content

Commit

Permalink
Renamed SubredditPostSupplier
Browse files Browse the repository at this point in the history
  • Loading branch information
yvasyliev committed Oct 20, 2023
1 parent 52c9059 commit 750be69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.stream.StreamSupport;

@Service
public class RedditPostService {
private static final Logger LOGGER = LoggerFactory.getLogger(RedditPostService.class);
public class SubredditPostSupplier implements ThrowingSupplier<List<Post>> {
private static final Logger LOGGER = LoggerFactory.getLogger(SubredditPostSupplier.class);

@Autowired
private ThrowingSupplier<JsonNode> subredditNewSupplier;
Expand All @@ -36,7 +36,8 @@ public class RedditPostService {
@Autowired
private ObjectMapper objectMapper;

public List<Post> findNewPosts() throws Exception {
@Override
public List<Post> getWithException() throws Exception {
var subredditPosts = subredditNewSupplier.getWithException();
var children = subredditPosts
.get("data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.yvasyliev.bots.telegram.RedTelBot;
import com.github.yvasyliev.model.dto.RedditPostDecisionData;
import com.github.yvasyliev.model.dto.post.Post;
import com.github.yvasyliev.service.reddit.RedditPostService;
import com.github.yvasyliev.service.reddit.SubredditPostSupplier;
import com.github.yvasyliev.service.state.StateManager;
import com.github.yvasyliev.service.telegram.posts.PhotoGroupPostService;
import com.github.yvasyliev.service.telegram.posts.PostService;
Expand Down Expand Up @@ -35,7 +35,7 @@ public class PostManager {
private ScheduledExecutorService executorService;

@Autowired
private RedditPostService redditPostService;
private SubredditPostSupplier subredditPostSupplier;

@Autowired
private RedTelBot redTelBot;
Expand All @@ -61,7 +61,7 @@ public void schedulePosting() {
executorService.scheduleWithFixedDelay(() -> {
if (publishing.get()) {
try {
var newPosts = redditPostService.findNewPosts();
var newPosts = subredditPostSupplier.getWithException();
publishPosts(newPosts);
} catch (Exception e) {
LOGGER.error("Failed to find new posts.", e);
Expand Down

0 comments on commit 750be69

Please sign in to comment.