Updated subscriptions
This commit is contained in:
@@ -140,3 +140,33 @@ func (m *AlertRuleModel) Remove(ctx context.Context, id int) (bool, error) {
|
||||
}
|
||||
return tag.RowsAffected() > 0, nil
|
||||
}
|
||||
|
||||
// DisableAllForUser sets enabled = false on every alert rule owned by addresses of userID.
|
||||
func (m *AlertRuleModel) DisableAllForUser(ctx context.Context, userID string) (int64, error) {
|
||||
tag, err := m.pool.Exec(ctx,
|
||||
`UPDATE alert_rules ar
|
||||
SET enabled = FALSE
|
||||
FROM addresses a
|
||||
WHERE ar.address_id = a.id AND a.user_id = $1`,
|
||||
userID,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return tag.RowsAffected(), nil
|
||||
}
|
||||
|
||||
// EnableAllForUser sets enabled = true on every alert rule owned by addresses of userID.
|
||||
func (m *AlertRuleModel) EnableAllForUser(ctx context.Context, userID string) (int64, error) {
|
||||
tag, err := m.pool.Exec(ctx,
|
||||
`UPDATE alert_rules ar
|
||||
SET enabled = TRUE
|
||||
FROM addresses a
|
||||
WHERE ar.address_id = a.id AND a.user_id = $1`,
|
||||
userID,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return tag.RowsAffected(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user