mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(notifications): Add Gotify (#1180)
feat(notifications): Add Gotify (resolves #513)
This commit is contained in:
parent
525861074b
commit
77948d7654
8 changed files with 233 additions and 6 deletions
|
@ -31,7 +31,7 @@ func NewNotificationRepo(log logger.Logger, db *DB) domain.NotificationRepo {
|
|||
func (r *NotificationRepo) Find(ctx context.Context, params domain.NotificationQueryParams) ([]domain.Notification, int, error) {
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
Select("id", "name", "type", "enabled", "events", "webhook", "token", "api_key", "channel", "priority", "topic", "created_at", "updated_at", "COUNT(*) OVER() AS total_count").
|
||||
Select("id", "name", "type", "enabled", "events", "webhook", "token", "api_key", "channel", "priority", "topic", "host", "created_at", "updated_at", "COUNT(*) OVER() AS total_count").
|
||||
From("notification").
|
||||
OrderBy("name")
|
||||
|
||||
|
@ -52,9 +52,9 @@ func (r *NotificationRepo) Find(ctx context.Context, params domain.NotificationQ
|
|||
for rows.Next() {
|
||||
var n domain.Notification
|
||||
|
||||
var webhook, token, apiKey, channel, topic sql.NullString
|
||||
var webhook, token, apiKey, channel, host, topic sql.NullString
|
||||
|
||||
if err := rows.Scan(&n.ID, &n.Name, &n.Type, &n.Enabled, pq.Array(&n.Events), &webhook, &token, &apiKey, &channel, &n.Priority, &topic, &n.CreatedAt, &n.UpdatedAt, &totalCount); err != nil {
|
||||
if err := rows.Scan(&n.ID, &n.Name, &n.Type, &n.Enabled, pq.Array(&n.Events), &webhook, &token, &apiKey, &channel, &n.Priority, &topic, &host, &n.CreatedAt, &n.UpdatedAt, &totalCount); err != nil {
|
||||
return nil, 0, errors.Wrap(err, "error scanning row")
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ func (r *NotificationRepo) Find(ctx context.Context, params domain.NotificationQ
|
|||
n.Token = token.String
|
||||
n.Channel = channel.String
|
||||
n.Topic = topic.String
|
||||
n.Host = host.String
|
||||
|
||||
notifications = append(notifications, n)
|
||||
}
|
||||
|
@ -182,6 +183,7 @@ func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notifi
|
|||
apiKey := toNullString(notification.APIKey)
|
||||
channel := toNullString(notification.Channel)
|
||||
topic := toNullString(notification.Topic)
|
||||
host := toNullString(notification.Host)
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
Insert("notification").
|
||||
|
@ -196,6 +198,7 @@ func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notifi
|
|||
"channel",
|
||||
"priority",
|
||||
"topic",
|
||||
"host",
|
||||
).
|
||||
Values(
|
||||
notification.Name,
|
||||
|
@ -208,6 +211,7 @@ func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notifi
|
|||
channel,
|
||||
notification.Priority,
|
||||
topic,
|
||||
host,
|
||||
).
|
||||
Suffix("RETURNING id").RunWith(r.db.handler)
|
||||
|
||||
|
@ -230,6 +234,7 @@ func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notif
|
|||
apiKey := toNullString(notification.APIKey)
|
||||
channel := toNullString(notification.Channel)
|
||||
topic := toNullString(notification.Topic)
|
||||
host := toNullString(notification.Host)
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
Update("notification").
|
||||
|
@ -243,6 +248,7 @@ func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notif
|
|||
Set("channel", channel).
|
||||
Set("priority", notification.Priority).
|
||||
Set("topic", topic).
|
||||
Set("host", host).
|
||||
Set("updated_at", sq.Expr("CURRENT_TIMESTAMP")).
|
||||
Where(sq.Eq{"id": notification.ID})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue