Conversation
f685cf3 to
0201ab9
Compare
065941a to
c086792
Compare
c086792 to
e6fd993
Compare
e6fd993 to
1608291
Compare
1608291 to
1bc7bb9
Compare
1bc7bb9 to
a61018e
Compare
937980a to
66d0f18
Compare
b0b158c to
289f1a1
Compare
289f1a1 to
6ffba2d
Compare
178b9db to
cbeb003
Compare
I changed the strategy for checking for existing emails; before I was searching based on the user profile language, but realized that we would miss messages if the user changed their language preference. What I didn't do was reload a prod-sized user set and retest. It didn't hang on my machine, but it did take a really, really long time. The staff test works against a much smaller subset of users. I'll just switch back to the original strategy, which runs much faster, and should only result in a few possible edge cases of duplicate emails. |
- dramatic speedup - more informative log messages during execution Bug: T409420
I benchmarked several approaches with a large number of users and we now have the best of both worlds; the user query now happens quickly and we still search for all current translations of the subject line. |
Bug: T412427
|
|
||
| # All Wikipedia Library users who: | ||
| for user in ( | ||
| users = ( |
There was a problem hiding this comment.
@suecarmol @DHardy-WMF @katydidnot I added in support for the qualification exemptions: I did some checks and found that they had a small impact on the recipient count. Should make testing a little easier!
TWLight/emails/backends/mediawiki.py
Outdated
| return wrapper | ||
|
|
||
|
|
||
| def _handle_maxlag(response): |
There was a problem hiding this comment.
@DHardy-WMF if you have a local db setup that supports maxlag, I'd appreciate at least some minimal manual testing on this. This function is completely untested.
TWLight/emails/backends/mediawiki.py
Outdated
| "There was an error in the request to send the email." | ||
| ) | ||
| emailuser_data = _handle_maxlag(emailuser_response) | ||
| if emailuser_data["emailuser"]["result"] != "Success": |
There was a problem hiding this comment.
After confirming my email address locally with a test account, I'm still seeing the following error on send:
{'error': {'code': 'cantsend', 'info': 'No send address', '*': 'See http://localhost:8080/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes.'}}
Curious if anyone else is seeing this?
There was a problem hiding this comment.
Just tested this locally and "successfully" sent 10 emails in different languages, so it's working for me!
There was a problem hiding this comment.
@suecarmol
When testing this locally did you use the API with a locally confirmed user? How did you setup that test user? Any specific steps beyond visiting the local confirmation page from mailhog?
There was a problem hiding this comment.
{'error': {'code': 'cantsend', 'info': 'No send address', '*': 'See http://localhost:8080/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes.'}}
@katydidnot I think this looks like mediawiki doesn't know what the "from" address should be? So, maybe it's on the mw config side rather than the user account side?
There was a problem hiding this comment.
hmm, no, it looks like the api talks about the target/to/recipient/send address interchangeably
There was a problem hiding this comment.
I've discovered some bugs in my maxlag handling code while looking at this; rejiggering!
There was a problem hiding this comment.
@katydidnot, I used my personal account and changed the relevant information in the DB so that it matched the personal account I created in my MW local environment. I also saw that other emails were "sent" (they were printed on the console) to other users that qualified.
There was a problem hiding this comment.
@katydidnot I still haven't been able to reproduce this, but I have now improved error handling and retry logic quite a bit.
suecarmol
left a comment
There was a problem hiding this comment.
Tested this locally and was able to "send" emails in different languages. Thank you for your work on this!
f5415c7 to
5be5d7d
Compare
5be5d7d to
c2cd3e6
Compare
- correct connection and maxlag retry bugs - bubble up api error messages - include usernames in exceptions for unsendable messages - more DRY Bug: T412427
c2cd3e6 to
3c1a3ac
Compare
|
I was trying to review this patch locally, unfortunately this is all I see when I run the command: Could be due to OAuth not going through the local MediaWiki instance. Is my TWLight misconfigured somehow? |
|
@jsnshrmn, when I run |

provides features required for mass emailing for survey mediawiki API.
Rationale
In T412427, we found that we were unable to send high volume mail via WMF cloud VPS SMTP infrastructure. So, we're going to try using mediawiki instead.
Phabricator Ticket
https://phabricator.wikimedia.org/T409420
How Has This Been Tested?
You can test run the command logic and djmail message tracking by passing through the default djmail backend (which should be console email for local dev).
For example:
python manage.py survey_active_users 000001 en fr de ja ru es --backend djmail.backends.default.EmailBackend --batch_size 10You may omit the backend to send it through the api, but in mediawiki you'll need to add and confirm email addresses for users with wp_usernames that match users in your TWLight. If you setup something like mailhog in mediawiki to handle mail delivery, you'll be able to see the survey messages accumulate there. It's kind of a pain.
Screenshots of your changes (if appropriate):
N/A
Types of changes
What types of changes does your code introduce? Add an
xin all the boxes that apply: