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

Replace set() by dict comprehension in recipients for new comments #2886

Merged

Conversation

maudetes
Copy link
Contributor

@maudetes maudetes commented Aug 29, 2023

Member of an organization that have taken part in a discussion on one of its documents are notified twice by mail about a new comment.

Indeed, set(recipients) does not work as expected, probably because it uses __hash__, that should be defined based on primary key, but is overridden in the context of UserMixin.

We're replacing it by a dict comprehension on user.id to make sure we have only one occurrence of each user.

See https://mattermost.incubateur.net/betagouv/pl/q91rpukpatna9jfbryiafqq7rw for context.

@maudetes maudetes changed the title Replace set() by dict comprehension Replace set() by dict comprehension in recipients for new comments Aug 29, 2023
@maudetes maudetes requested a review from quaxsze August 29, 2023 13:00
@@ -550,3 +551,76 @@ def test_notify_org_discussions(self):
self.assertEqual(details['title'], discussion.title)
self.assertEqual(details['subject']['id'], discussion.subject.id)
self.assertEqual(details['subject']['type'], 'dataset')


class DiscussionsMailsTest(APITestCase):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly copied from udata-front

@maudetes maudetes merged commit beb08a2 into opendatateam:master Aug 29, 2023
1 check passed
@maudetes maudetes deleted the fix/unique-recipient-discussion branch August 29, 2023 15:20
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 this pull request may close these issues.

None yet

2 participants