From 927f67c0bb8b9d2ad1a3c04bc0675de51f7eee1a Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Tue, 19 Mar 2024 18:26:45 -0400 Subject: [PATCH] fix merge user mailchimp subscriptions --- osf/external/messages/celery_publishers.py | 4 ++-- osf_tests/test_user.py | 4 ++-- website/profile/views.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osf/external/messages/celery_publishers.py b/osf/external/messages/celery_publishers.py index f9bbb1490e10..430fee847980 100644 --- a/osf/external/messages/celery_publishers.py +++ b/osf/external/messages/celery_publishers.py @@ -31,8 +31,8 @@ def publish_merged_user(user): _publish_user_status_change.s( body={ 'action': 'merge', - 'user_uri': user.get_semantic_iri(), - 'merged_user_uri': user.merged_by.get_semantic_iri(), + 'into_user_uri': user.get_semantic_iri(), + 'from_user_uri': user.merged_by.get_semantic_iri(), }, ) ) diff --git a/osf_tests/test_user.py b/osf_tests/test_user.py index a304f3765ca1..a2b1912f5482 100644 --- a/osf_tests/test_user.py +++ b/osf_tests/test_user.py @@ -17,7 +17,7 @@ from importlib import import_module from framework.auth.exceptions import ExpiredTokenError, InvalidTokenError, ChangePasswordError -from framework.auth.signals import user_account_merged, user_account_deactivated +from framework.auth.signals import user_account_merged from framework.analytics import get_total_activity_count from framework.exceptions import PermissionsError from framework.celery_tasks import handlers @@ -1507,7 +1507,7 @@ def test_send_user_merged_signal(self, mock_get_mailchimp_api, dupe, merge_dupe) with capture_signals() as mock_signals: merge_dupe() - assert mock_signals.signals_sent() == set([user_account_merged, user_account_deactivated]) + assert mock_signals.signals_sent() == set([user_account_merged]) @pytest.mark.enable_enqueue_task @mock.patch('website.mailchimp_utils.get_mailchimp_api') diff --git a/website/profile/views.py b/website/profile/views.py index 4f9bbd64fb7f..155d1531a4c1 100644 --- a/website/profile/views.py +++ b/website/profile/views.py @@ -545,7 +545,7 @@ def send_account_merged_message(user): def unsubscribe_old_merged_account_from_mailchimp(user): """ This is a merged account (an old account that was merged into an active one) so it needs to be unsubscribed from mailchimp.""" - for key, value in user.mailchimp_mailing_lists.items(): + for key, value in user.merged_by.mailchimp_mailing_lists.items(): if value: update_mailchimp_subscription(user, list_name=key, subscription=key) update_mailchimp_subscription(user.merged_by, list_name=key, subscription=False)