Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] User receives multiple identical notifications #277

Closed
kkreitmair opened this issue Jun 4, 2024 · 0 comments · Fixed by #278
Closed

[bug] User receives multiple identical notifications #277

kkreitmair opened this issue Jun 4, 2024 · 0 comments · Fixed by #278
Assignees

Comments

@kkreitmair
Copy link
Contributor

kkreitmair commented Jun 4, 2024

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.
@kkreitmair kkreitmair self-assigned this Jun 4, 2024
kkreitmair added a commit to kkreitmair/openwisp-notifications that referenced this issue Jun 4, 2024
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,
does a LEFT OUTER JOIN with the "openwisp_users_organizationuser" table.
In this table, a user is multiple times listed,
when he is in several organizations.
Therefore the query returns such a user multiple times,
which will then receive multiple identical notifications.
This commit fixes this bug by adding a distinct to all user queries.

Fixes openwisp#277

Signed-off-by: Konrad Kreitmair <kkreitmair@tdt.de>
kkreitmair added a commit to kkreitmair/openwisp-notifications that referenced this issue Jun 4, 2024
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,
does a LEFT OUTER JOIN with the "openwisp_users_organizationuser" table.
In this table, a user is multiple times listed,
when he is in several organizations.
Therefore the query returns such a user multiple times,
which will then receive multiple identical notifications.
This commit fixes this bug by adding a distinct to all user queries.

Fixes openwisp#277

Signed-off-by: Konrad Kreitmair <kkreitmair@tdt.de>
kkreitmair added a commit to kkreitmair/openwisp-notifications that referenced this issue Jun 11, 2024
…penwisp#277

This should prevent regression to the behavior of the related issue.

Related to openwisp#277

Signed-off-by: Konrad Kreitmair <kkreitmair@tdt.de>
kkreitmair added a commit to kkreitmair/openwisp-notifications that referenced this issue Jun 11, 2024
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,
does a LEFT OUTER JOIN with the "openwisp_users_organizationuser" table.
In this table, a user is multiple times listed,
when he is in several organizations.
Therefore the query returns such a user multiple times,
which will then receive multiple identical notifications.
This commit fixes this bug by adding a distinct to all user queries.

Fixes openwisp#277

Signed-off-by: Konrad Kreitmair <kkreitmair@tdt.de>
kkreitmair added a commit to kkreitmair/openwisp-notifications that referenced this issue Jun 11, 2024
…penwisp#277

This should prevent regression to the behavior of the related issue.

Related to openwisp#277

Signed-off-by: Konrad Kreitmair <kkreitmair@tdt.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant