Skip to content

Commit

Permalink
Disable notifs
Browse files Browse the repository at this point in the history
Signed-off-by: Jason <[email protected]>
  • Loading branch information
JasonLovesDoggo committed Sep 3, 2024
1 parent 8bf4f27 commit 4fdd3fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 17 additions & 10 deletions core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def run_group_migrations():

@app.task
def notif_broker_announcement(obj_id):
if not settings.NOTIFICATIONS_ENABLED:
return
logger.info(f"notif_broker_announcement for {obj_id}")
try:
ann = Announcement.objects.get(id=obj_id)
Expand Down Expand Up @@ -132,20 +134,23 @@ def notif_broker_blogpost(obj_id):
except BlogPost.DoesNotExist:
logger.warning(f"notif_broker_blogpost: blogpost {obj_id} does not exist")
return
affected = users_with_token()
for u in affected.all():
notif_single.delay(
u.id,
dict(
title=_l("New Blog Post: %(title)s") % dict(title=post.title),
body=post.body,
category="blog",
),
)
if settings.NOTIFICATIONS_ENABLED:
affected = users_with_token()
for u in affected.all():
notif_single.delay(
u.id,
dict(
title=_l("New Blog Post: %(title)s") % dict(title=post.title),
body=post.body,
category="blog",
),
)


@app.task
def notif_events_singleday(date: dt.date = None):
if not settings.NOTIFICATIONS_ENABLED:
return
tz = pytz.timezone(settings.TIME_ZONE)
if date is None:
date = dt.date.today() + dt.timedelta(days=1)
Expand Down Expand Up @@ -190,6 +195,8 @@ def notif_events_singleday(date: dt.date = None):

@app.task(bind=True)
def notif_single(self, recipient_id: int, msg_kwargs):
if not settings.NOTIFICATIONS_ENABLED:
return
recipient = User.objects.get(id=recipient_id)
logger.info(
f"notif_single to {recipient} ({recipient.expo_notif_tokens}): {msg_kwargs}"
Expand Down
1 change: 1 addition & 0 deletions metropolis/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@
ANNOUNCEMENTS_NOTIFY_FEEDS = [] # list of PKs of organizations
EVENTS_NOTIFY_FEEDS = [] # list of PKs of organizations
NOTIF_DRY_RUN = True
NOTIFICATIONS_ENABLED = False


def is_aware(d: datetime) -> bool:
Expand Down

0 comments on commit 4fdd3fb

Please sign in to comment.