Skip to content

Commit

Permalink
Merge pull request #8 from opendata-swiss/master
Browse files Browse the repository at this point in the history
Only send notifications for subscriptions that are verified
  • Loading branch information
bellisk authored Jan 3, 2023
2 parents 8db060c + 895d37e commit 0d41b6c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckanext/subscribe/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ def get_objects_subscribed_to(subscription_frequency):
objects_subscribed_to = defaultdict(list) # {object_id: [subscriptions]}
# direct subscriptions - i.e. datasets, orgs & groups
for subscription in model.Session.query(Subscription) \
.filter(Subscription.verified.is_(True)) \
.filter(Subscription.frequency == subscription_frequency).all():
objects_subscribed_to[subscription.object_id].append(subscription)
# also include the datasets attached to the subscribed orgs
for subscription, package_id in model.Session.query(Subscription, Package.id) \
.filter(Subscription.verified.is_(True)) \
.filter(Subscription.frequency == subscription_frequency) \
.join(Group, Group.id == Subscription.object_id) \
.filter(Group.state == 'active') \
Expand All @@ -156,6 +158,7 @@ def get_objects_subscribed_to(subscription_frequency):
objects_subscribed_to[package_id].append(subscription)
# also include the datasets attached to the subscribed orgs
for subscription, package_id in model.Session.query(Subscription, Package.id) \
.filter(Subscription.verified.is_(True)) \
.filter(Subscription.frequency == subscription_frequency) \
.join(Group, Group.id == Subscription.object_id) \
.filter(Group.state == 'active') \
Expand Down

0 comments on commit 0d41b6c

Please sign in to comment.