Skip to content

Commit 20512d6

Browse files
committed
Merge branch 'fix-notification-update' into 'main'
Fix remote notification disappearing after refetch See merge request reportcreator/reportcreator!1076
2 parents 8057d53 + 629140c commit 20512d6

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Upcoming
4+
* Fix remote notification disappearing after refetch
5+
6+
37
## v2025.83 - 2025-09-26
48
* Suggest previously used tags in filters, projects, designs and templates
59
* Plugin `scanimport`: Prevent errors on incompatible finding field types

api/src/sysreptor/notifications/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create(self, validated_data):
3838
.update(active_until=(timezone.now() - timedelta(days=1)).date())
3939
UserNotification.objects \
4040
.filter(remotenotificationspec__isnull=False) \
41-
.exclude(id__in=[n.id for n in notifications]) \
41+
.exclude(remotenotificationspec_id__in=[n.id for n in notifications]) \
4242
.update(visible_until=timezone.now())
4343

4444
# Create new notifications

api/src/sysreptor/tests/test_notifications.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,33 @@ def test_create(self):
119119

120120
def test_refetch(self):
121121
async_to_sync(fetch_notifications)(None)
122-
before = RemoteNotificationSpec.objects.get()
122+
rn_before = RemoteNotificationSpec.objects.get()
123+
un_before = self.user_notification.notifications.get()
123124
async_to_sync(fetch_notifications)(None)
124-
after = RemoteNotificationSpec.objects.get()
125-
assertKeysEqual(before, after, ['id', 'created', 'updated', 'active_until'])
125+
rn_after = RemoteNotificationSpec.objects.get()
126+
assertKeysEqual(rn_before, rn_after, ['id', 'created', 'updated', 'active_until'])
127+
un_after = self.user_notification.notifications.get()
128+
assertKeysEqual(un_before, un_after, ['id', 'created', 'user', 'type', 'remotenotificationspec_id', 'visible_until', 'read', 'additional_content'])
126129

127130
def test_delete(self):
128131
async_to_sync(fetch_notifications)(None)
129132
self.notification_import_data = []
130133
async_to_sync(fetch_notifications)(None)
134+
135+
# RemoteNotificationSpec is set to inactive
131136
after = RemoteNotificationSpec.objects.get()
132137
notification = self.user_notification.notifications.get(remotenotificationspec=after)
133138
assert after.active_until < timezone.now().date()
134139
assert notification.visible_until < timezone.now()
135140

141+
# User notifications are set to invisible
142+
un1 = self.user_notification.notifications.get(remotenotificationspec=after)
143+
assert un1.visible_until < timezone.now()
144+
145+
# No new notifications are created
146+
u = create_user()
147+
assert u.notifications.all().count() == 0
148+
136149

137150
@pytest.mark.django_db()
138151
class TestNotificationTriggers:

0 commit comments

Comments
 (0)