forked from quarkusio/quarkus-github-lottery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotificationService.java
34 lines (27 loc) · 1.32 KB
/
NotificationService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.quarkus.github.lottery.notification;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import io.quarkus.github.lottery.config.LotteryConfig;
import io.quarkus.github.lottery.draw.DrawRef;
import io.quarkus.github.lottery.github.GitHubRepository;
import io.quarkus.github.lottery.github.GitHubRepositoryRef;
import io.quarkus.github.lottery.github.GitHubService;
import io.quarkus.github.lottery.message.MessageFormatter;
@ApplicationScoped
public class NotificationService {
public static GitHubRepository notificationRepository(GitHubService gitHubService, DrawRef drawRef,
LotteryConfig.NotificationsConfig config) {
return gitHubService.repository(new GitHubRepositoryRef(drawRef.repositoryRef().installationRef(),
config.createIssues().repository()));
}
@Inject
MessageFormatter formatter;
@Inject
GitHubService gitHubService;
public Notifier notifier(DrawRef drawRef, LotteryConfig.NotificationsConfig config) {
GitHubRepository notificationRepo = notificationRepository(gitHubService, drawRef, config);
// TODO check that the repo exists and we have access to it right now, to fail fast?
// Might be useful for config linting as well.
return new Notifier(formatter, drawRef, notificationRepo);
}
}