mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(irc): improve reconnect and add notifications (#315)
* refactor(irc): nickserv and methods * feat(notifications): add new events and refactor send * feat(irc): handle disconnect reconnect and connect * feat(irc): update config for ergo local irc server * feat(irc): retry initial connect * feat(irc): show nickserv errors
This commit is contained in:
parent
41eef4e8be
commit
f63ace662a
16 changed files with 1343 additions and 133 deletions
|
@ -140,6 +140,10 @@ func (a *discordSender) buildEmbed(event domain.NotificationEvent, payload domai
|
|||
color = GRAY
|
||||
case domain.NotificationEventPushError:
|
||||
color = RED
|
||||
case domain.NotificationEventIRCDisconnected:
|
||||
color = RED
|
||||
case domain.NotificationEventIRCReconnected:
|
||||
color = GREEN
|
||||
case domain.NotificationEventTest:
|
||||
color = LIGHT_BLUE
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ type Service interface {
|
|||
Store(ctx context.Context, n domain.Notification) (*domain.Notification, error)
|
||||
Update(ctx context.Context, n domain.Notification) (*domain.Notification, error)
|
||||
Delete(ctx context.Context, id int) error
|
||||
Send(event domain.NotificationEvent, payload domain.NotificationPayload) error
|
||||
Send(event domain.NotificationEvent, payload domain.NotificationPayload)
|
||||
Test(ctx context.Context, notification domain.Notification) error
|
||||
}
|
||||
|
||||
|
@ -109,17 +109,19 @@ func (s *service) registerSenders() {
|
|||
}
|
||||
|
||||
// Send notifications
|
||||
func (s *service) Send(event domain.NotificationEvent, payload domain.NotificationPayload) error {
|
||||
func (s *service) Send(event domain.NotificationEvent, payload domain.NotificationPayload) {
|
||||
s.log.Debug().Msgf("sending notification for %v", string(event))
|
||||
|
||||
for _, sender := range s.senders {
|
||||
// check if sender is active and have notification types
|
||||
if sender.CanSend(event) {
|
||||
sender.Send(event, payload)
|
||||
go func() {
|
||||
for _, sender := range s.senders {
|
||||
// check if sender is active and have notification types
|
||||
if sender.CanSend(event) {
|
||||
sender.Send(event, payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) Test(ctx context.Context, notification domain.Notification) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue