Skip to content

Commit

Permalink
fix merge user mailchimp subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Mar 20, 2024
1 parent 7b0f611 commit 927f67c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions osf/external/messages/celery_publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
)
)
Expand Down
4 changes: 2 additions & 2 deletions osf_tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion website/profile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 927f67c

Please sign in to comment.