Skip to content

Commit 3d1f654

Browse files
committed
feat: webhook enable ondemand
1 parent 72c892a commit 3d1f654

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

src/main/kotlin/cn/scutbot/sim/rmdispatcher/config/WebhookConfig.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
33

44
@ConfigurationProperties(prefix = "webhook")
55
data class WebhookConfig(
6-
val endpoints: Set<String>
6+
var enabled: Boolean = false,
7+
var endpoints: Set<String> = emptySet()
78
)

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/WebhookMatchEndListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import cn.scutbot.sim.rmdispatcher.data.dji.Match
44
import cn.scutbot.sim.rmdispatcher.listener.IMatchEndListener
55
import cn.scutbot.sim.rmdispatcher.service.IWebhookService
66
import org.springframework.beans.factory.annotation.Autowired
7+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
78
import org.springframework.stereotype.Component
89

910
@Component
11+
@ConditionalOnProperty(prefix = "webhook", name = ["enabled"], havingValue = "true")
1012
class WebhookMatchEndListener(
1113
@Autowired val webhookService: IWebhookService
1214
) : IMatchEndListener {

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/WebhookMatchSessionEndListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import cn.scutbot.sim.rmdispatcher.data.dji.Match
44
import cn.scutbot.sim.rmdispatcher.listener.IMatchSessionEndListener
55
import cn.scutbot.sim.rmdispatcher.service.IWebhookService
66
import org.springframework.beans.factory.annotation.Autowired
7+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
78
import org.springframework.stereotype.Component
89

910
@Component
11+
@ConditionalOnProperty(prefix = "webhook", name = ["enabled"], havingValue = "true")
1012
class WebhookMatchSessionEndListener(
1113
@Autowired val webhookService: IWebhookService
1214
) : IMatchSessionEndListener {

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/WebhookMatchStartListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import cn.scutbot.sim.rmdispatcher.data.dji.Match
44
import cn.scutbot.sim.rmdispatcher.listener.IMatchStartListener
55
import cn.scutbot.sim.rmdispatcher.service.IWebhookService
66
import org.springframework.beans.factory.annotation.Autowired
7+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
78
import org.springframework.scheduling.annotation.Async
89
import org.springframework.stereotype.Component
910

1011
@Component
12+
@ConditionalOnProperty(prefix = "webhook", name = ["enabled"], havingValue = "true")
1113
class WebhookMatchStartListener(
1214
@Autowired val webhookService: IWebhookService
1315
) : IMatchStartListener {

0 commit comments

Comments
 (0)