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

Email settings user widget - can't subscribe user to list #1

Open
ricco24 opened this issue Jul 10, 2020 · 4 comments
Open

Email settings user widget - can't subscribe user to list #1

ricco24 opened this issue Jul 10, 2020 · 4 comments

Comments

@ricco24
Copy link

ricco24 commented Jul 10, 2020

EmailSettingsFormFactory in formSucceeded loads only user preferences. So user can't be subscribed to new created mailing list because user doesn't have record in user_subscriptions table for this list.

@rootpd
Copy link
Member

rootpd commented Jul 13, 2020

Hm, that's weird. Creating mailing list should trigger creation of mail_user_subscription record in Mailer. Looking at the handler, I see the issue: https://github.com/remp2020/remp/blob/master/Mailer/app/hermes/ListCreatedHandler.php#L41

We'll remove this line so the record is always created correctly.

Until then, please run php bin/command.php mail:sync-user-subscriptions in Mailer to add missing mail subscription records.

rootpd added a commit to remp2020/remp that referenced this issue Jul 13, 2020
This check caused lists without auto_subscribe not to have "unsubscribed"
records. Features dependent on user subscriptions completeness were not
able to subscribe user to the list, because it never appeared in their
preferences.

remp2020/crm-remp-mailer-module#1
@ricco24
Copy link
Author

ricco24 commented Aug 27, 2020

As i see this is not problem with mailer but with mailer module. In EmailSettingsFormFactory is iteration only over userPreferences.

$userPreferences = $this->mailUserSubscriptionsRepository->userPreferences($values['user_id']);

So if user has no record for list in mail_user_subscriptions then it is impossible to subscribe user via this widet to this list.

@ricco24
Copy link
Author

ricco24 commented Aug 27, 2020

After your fix in mailer i think this problem persists only on not auto subscribe lists.

@rootpd
Copy link
Member

rootpd commented Aug 31, 2020

@ricco24 Reading userPreferences is intentional, as there's an expectation that Mailer keeps track of all newsletter-user subscription combinations. That means that each user should have record (userPreference) for each newsletter whether she is subscribed to it or not. That's why reading userPreferences` should be sufficient.

When the new user is registered, CRM calls Register API to create these records (see highlighted lines):
https://github.com/remp2020/remp/blob/master/Mailer/app/api/v1/Handlers/Users/UserRegisteredHandler.php#L65

And when new newsletter is created in Mailer, it's handled by the handler I referenced before:
https://github.com/remp2020/remp/blob/master/Mailer/app/hermes/ListCreatedHandler.php#L47

It looks to me that there are only these two scenarios that can affect mail_user_subscriptions and both are covered by CRM's Mailer module and by REMP Mailer.

Are you still seeing the issue, after running the mail:sync-user-subscriptions command and trying the fixed version from July 13+? If so, is there a way how to identify the users with missing newsletter subscription info? (whether they're new registrations?)

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

No branches or pull requests

2 participants