Patchwork FYI: new emails from phabricator can be replied to

login
register
mail settings
Submitter Jun Wu
Date Sept. 7, 2017, 8:27 p.m.
Message ID <1504816003-sup-1373@x1c>
Download mbox | patch
Permalink /patch/23735/
State Not Applicable
Headers show

Comments

Jun Wu - Sept. 7, 2017, 8:27 p.m.
Excerpts from Jun Wu's message of 2017-09-07 13:24:27 -0700:
> Excerpts from Augie Fackler's message of 2017-09-07 14:54:56 -0400:
> > Hopefully this means if you don't have a phabricator account, you can
> > still get comments attached to phabricator-sent patches.
> 
> By default Phabricator requires "From" address to match an existing user.
> 
> I think we can patch Phabricator to allow replying using a dummy user
> account if not registered.
> 
> diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> index 05b44f364..2beb88119 100644
> --- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> +++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> @@ -100,6 +100,11 @@ abstract class PhabricatorMailReceiver extends Phobject {
>  
>      // Try to find a user with this email address.
>      $user = PhabricatorUser::loadOneWithEmailAddress($from);
> +    if (!$user) {
> +      // Use a predefined fallback user
> +      $from = PhabricatorEnv::getEnvConfigIfExists('metamta.fallback-from');
> +      $user = PhabricatorUser::loadOneWithEmailAddress($from);
> +    }
>      if ($user) {
>        return $user;
>      } else {

Sorry but the above code missed a "null" check. I didn't have email infra to
test the patch but in theory it should work:

Patch

diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
index 05b44f364..030962142 100644
--- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
+++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
@@ -100,6 +100,13 @@  abstract class PhabricatorMailReceiver extends Phobject {
 
     // Try to find a user with this email address.
     $user = PhabricatorUser::loadOneWithEmailAddress($from);
+    if (!$user) {
+      // Use a predefined default user
+      $from = PhabricatorEnv::getEnvConfigIfExists('metamta.fallback-from');
+      if ($from) {
+        $user = PhabricatorUser::loadOneWithEmailAddress($from);
+      }
+    }
     if ($user) {
       return $user;
     } else {