mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-16 08:05:49 -06:00
Put more things in tx
This commit is contained in:
parent
8afeb813d9
commit
c864a9baeb
1 changed files with 6 additions and 5 deletions
|
|
@ -130,12 +130,13 @@ func (s *Store) RemoveSubscriptionsByUserID(userID string) error {
|
|||
|
||||
// RemoveExpiredSubscriptions removes all subscriptions that have not been updated for a given time period.
|
||||
func (s *Store) RemoveExpiredSubscriptions(expireAfter time.Duration) error {
|
||||
_, err := s.db.Exec(s.queries.deleteSubscriptionByAge, time.Now().Add(-expireAfter).Unix())
|
||||
if err != nil {
|
||||
return db.ExecTx(s.db, func(tx *sql.Tx) error {
|
||||
if _, err := tx.Exec(s.queries.deleteSubscriptionByAge, time.Now().Add(-expireAfter).Unix()); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := tx.Exec(s.queries.deleteSubscriptionTopicWithoutSubscription)
|
||||
return err
|
||||
}
|
||||
_, err = s.db.Exec(s.queries.deleteSubscriptionTopicWithoutSubscription)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// SetSubscriptionUpdatedAt updates the updated_at timestamp for a subscription by endpoint. This is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue