mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
feat(notification): add To field to LogMessage
This commit is contained in:
@@ -3,6 +3,7 @@ package notif
|
|||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ type (
|
|||||||
Title string
|
Title string
|
||||||
Body LogBody
|
Body LogBody
|
||||||
Color Color
|
Color Color
|
||||||
|
|
||||||
|
To []string
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyFunc func(msg *LogMessage)
|
NotifyFunc func(msg *LogMessage)
|
||||||
@@ -99,6 +102,9 @@ func (disp *Dispatcher) dispatch(msg *LogMessage) {
|
|||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for p := range disp.providers.Range {
|
for p := range disp.providers.Range {
|
||||||
|
if len(msg.To) > 0 && !slices.Contains(msg.To, p.GetName()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(p Provider) {
|
go func(p Provider) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|||||||
Reference in New Issue
Block a user