openwisp / openwisp-notifications

Notifications module of OpenWISP
https://openwisp.io/docs/dev/notifications/
GNU General Public License v3.0
40 stars 41 forks source link

[bug] User receives multiple identical notifications #277

Closed kkreitmair closed 3 months ago

kkreitmair commented 4 months ago

If a user is in several organizations, they will receive multiple identical notifications.

The reason for this is that the database query, which determines which user should receive the notification, can return a user multiple times.

Steps to replicate the issue:

  1. Do a fresh installation of openwisp-controller as described in the docs and launch the development server.
  2. Re-enable the "default" notification type by commenting out the lines 268 to 272 in openwisp_controller/config/apps.py.
  3. Log In to the admin site with the user created during installation.
  4. Create a second organization.
  5. Make the user organization user of the two organizations (is_admin is not required).
  6. Create a nottification type setting for the type "Default Type" with organization default, web notification checked and email notification checked.
  7. Then create a notification with the following command: env/bin/python tests/manage.py create_notification
  8. This user will then receive the notification twice.