Skip to content

Commit 752544d

Browse files
Merge pull request #132 from silverlogic/BA-1473-be-notifications-settings
BA-1400 Notifications Settings
2 parents d299282 + c32f7be commit 752544d

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

baseapp-comments/baseapp_comments/notifications.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def send_reply_created_notification(comment_pk):
1818
send_email=True,
1919
sender=comment.profile or comment.user,
2020
recipient=comment.in_reply_to.user,
21-
verb="COMMENT_REPLY_CREATED",
21+
verb="COMMENTS.COMMENT_REPLY_CREATED",
2222
action_object=comment,
2323
target=comment.in_reply_to,
2424
level="info",
@@ -40,7 +40,7 @@ def send_comment_created_notification(comment_pk, recipient_id):
4040
send_email=True,
4141
sender=comment.profile or comment.user,
4242
recipient=recipient,
43-
verb="COMMENT_CREATED",
43+
verb="COMMENTS.COMMENT_CREATED",
4444
action_object=comment,
4545
target=comment.target,
4646
level="info",

baseapp-notifications/baseapp_notifications/utils.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ def send_email_notification(to, context):
121121

122122
def can_user_receive_notification(user_id, verb, channel):
123123
NotificationSetting = swapper.load_model("baseapp_notifications", "NotificationSetting")
124-
user_setting = NotificationSetting.objects.filter(
125-
Q(channel=channel) | Q(channel=NotificationSetting.NotificationChannelTypes.ALL),
126-
user_id=user_id,
127-
verb=get_setting_from_verb(verb),
128-
).first()
124+
user_setting = (
125+
NotificationSetting.objects.filter(
126+
Q(channel=channel) | Q(channel=NotificationSetting.NotificationChannelTypes.ALL),
127+
Q(verb=get_setting_from_verb(verb)) | Q(verb="_ALL_"),
128+
user_id=user_id,
129+
)
130+
.order_by("is_active")
131+
.first()
132+
)
133+
129134
if user_setting:
130135
return user_setting.is_active
131136
return True

baseapp-notifications/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = baseapp_notifications
3-
version = 0.3.0
3+
version = 0.3.1
44
description = BaseApp Notifications
55
long_description = file: README.md
66
url = https://github.com/silverlogic/baseapp-backend

0 commit comments

Comments
 (0)