Make mail delivery reasons code-based; include positive and negative reasons


Make mail delivery reasons code-based; include positive and negative reasons

Ref T7731. Looking forward to T5791, I eventually anticipate writing an interface which looks like a webmail UI where users can review mail they've been sent and understand why they recieved (or did not receive) the mail. Roughly like bin/mail list-outbound / bin/mail show-outbound work today, but policy-aware (so you can only see messages where delivery was attempted to you).

We currently record a list of "reasons" why a mail is undeliverable, but this list is string-based (so it can not be translated once we start persisting it) and has only negative reasons (so it can not be used to fully understand reasons for delivery or nondelivery).

Make it code-based (so it can be translated) and allow both positive and negative reasons to be listed (so positive reasons can be understood).

Test Plan: Used bin/mail show-outbound to review mail delivery reasons, including the positive reason we currently have (forced delivery of authentication mail).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7731

Differential Revision: https://secure.phabricator.com/D12297

Event Timeline

nagym718 added a subscriber: nagym718.

896 888 }
897 889
898 890 $all_prefs = id(new PhabricatorUserPreferences())->loadAllWhere(
899 891 'userPHID in (%Ls)',
900 892 $actor_phids);
901 893 $all_prefs = mpull($all_prefs, null, 'getUserPHID');
902 894
903 895 Exclude recipients who don't want any mail.
904 896 foreach ($all_prefs as $phid => $prefs) {
905 897 $exclude = $prefs->getPreference(
906 898 PhabricatorUserPreferences::PREFERENCE_NO_MAIL,
907 899 false);
908 900 if ($exclude) {
909 901 $actors[$phid]->setUndeliverable(
910 pht(
911 'This recipient has disabled all email notifications '.
912 '(Settings > Email Preferences > Email Notifications).'));
902 PhabricatorMetaMTAActor::REASON_MAIL_DISABLED);
913 903 }
914 904 }
915 905
916 906 $value_email = PhabricatorUserPreferences::MAILTAG_PREFERENCE_EMAIL;
917 907
918 908
Exclude all recipients who have set preferences to not receive this type
919 909 // of email (for example, a user who says they don't want emails about task