feat: remove webhook subcription by url (#194)

* feat: added webhook unsubscription
* test: adding unsubscribe tests
This commit is contained in:
yse
2024-02-29 09:59:09 +01:00
committed by GitHub
parent ed6fd76b31
commit 11f35cbab1
9 changed files with 356 additions and 21 deletions

View File

@@ -76,6 +76,27 @@ func (s *NotificationsStore) GetRegistrations(
return result, nil
}
func (s *NotificationsStore) Unsubscribe(
ctx context.Context,
pubkey string,
url string,
) error {
pk, err := hex.DecodeString(pubkey)
if err != nil {
return err
}
_, err = s.pool.Exec(
ctx,
`DELETE FROM public.notification_subscriptions
WHERE pubkey = $1 AND url = $2`,
pk,
url,
)
return nil
}
func (s *NotificationsStore) RemoveExpired(
ctx context.Context,
before time.Time,