Closed kkreitmair closed 4 months ago
@nemesifier I updated the issue comment by a description how to replicate the issue. The test will follow soon.
@nemesifier I added the test.
In my patch, I naively added also a .distinct()
to the QuerySet, which is injected through a parameter of the function.
This can be a convenient functionality, but could be also seen as a bad practice, because normally the caller of the function should care about this.
So the question is if this change should stay or should be removed. What is your opinion on this?
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 #277