@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Using PhabricatorExternalAccount

Summary: Using PhabricatorExternalAccount in place maniphest.default-public-author.

Test Plan:
Using receivemail to see if the a new entry is made in the 'phabircator_user.user_externalaccount' table. Few things, I noticed that phabricator creates table 'user_externalaccout'. And now it throws up error 'Unknown column 'dateCreated' in 'field list''. Awaiting your comments.
{F41370}

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T1205

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

authored by

Zedstar and committed by
epriestley
f53cde8f 09ed9558

+64 -24
+3 -1
conf/default.conf.php
··· 547 547 // preferences. 548 548 'metamta.vary-subjects' => true, 549 549 550 - 551 550 // -- Auth ------------------------------------------------------------------ // 552 551 553 552 // Can users login with a username/password, or by following the link from ··· 849 848 850 849 // Contains a list of uninstalled applications 851 850 'phabricator.uninstalled-applications' => array(), 851 + 852 + // Allowing non-members to interact with tasks over email. 853 + 'phabricator.allow-email-users' => false, 852 854 853 855 // -- Welcome Screen -------------------------------------------------------- // 854 856
+8
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 153 153 $this->newOption('phabricator.cache-namespace', 'string', null) 154 154 ->setLocked(true) 155 155 ->setDescription(pht('Cache namespace.')), 156 + $this->newOption('phabricator.allow-email-users', 'bool', false) 157 + ->setBoolOptions( 158 + array( 159 + pht('Allow'), 160 + pht('Disallow'), 161 + ))->setDescription( 162 + pht( 163 + 'Allow non-members to interact with tasks over email.')), 156 164 ); 157 165 158 166 }
+40 -17
src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
··· 211 211 if ($user) { 212 212 $this->setAuthorPHID($user->getPHID()); 213 213 } else { 214 - $default_author = PhabricatorEnv::getEnvConfig( 215 - 'metamta.maniphest.default-public-author'); 214 + $allow_email_users = PhabricatorEnv::getEnvConfig( 215 + 'phabricator.allow-email-users'); 216 + 217 + if ($allow_email_users) { 218 + $email = new PhutilEmailAddress($from); 219 + 220 + $user = id(new PhabricatorExternalAccount())->loadOneWhere( 221 + 'accountType = %s AND accountDomain IS NULL and accountID = %s', 222 + 'email', $email->getAddress()); 223 + 224 + if (!$user) { 225 + $user = new PhabricatorExternalAccount(); 226 + $user->setAccountID($email->getAddress()); 227 + $user->setAccountType('email'); 228 + $user->setDisplayName($email->getDisplayName()); 229 + $user->save(); 230 + 231 + } 232 + 233 + } else { 234 + $default_author = PhabricatorEnv::getEnvConfig( 235 + 'metamta.maniphest.default-public-author'); 236 + 237 + if ($default_author) { 238 + $user = id(new PhabricatorUser())->loadOneWhere( 239 + 'username = %s', 240 + $default_author); 241 + 242 + if (!$user) { 243 + throw new Exception( 244 + "Phabricator is misconfigured, the configuration key ". 245 + "'metamta.maniphest.default-public-author' is set to user ". 246 + "'{$default_author}' but that user does not exist."); 247 + } 216 248 217 - if ($default_author) { 218 - $user = id(new PhabricatorUser())->loadOneWhere( 219 - 'username = %s', 220 - $default_author); 221 - if ($user) { 222 - $receiver->setOriginalEmailSource($from); 223 249 } else { 224 - throw new Exception( 225 - "Phabricator is misconfigured, the configuration key ". 226 - "'metamta.maniphest.default-public-author' is set to user ". 227 - "'{$default_author}' but that user does not exist."); 250 + // TODO: We should probably bounce these since from the user's 251 + // perspective their email vanishes into a black hole. 252 + return $this->setMessage("Invalid public user '{$from}'.")->save(); 228 253 } 229 - } else { 230 - // TODO: We should probably bounce these since from the user's 231 - // perspective their email vanishes into a black hole. 232 - return $this->setMessage("Invalid public user '{$from}'.")->save(); 233 254 } 255 + 234 256 } 235 257 236 258 $receiver->setAuthorPHID($user->getPHID()); 259 + $receiver->setOriginalEmailSource($from); 237 260 $receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE); 238 261 239 262 $editor = new ManiphestTransactionEditor(); ··· 242 265 243 266 $handler->setActor($user); 244 267 $handler->setExcludeMailRecipientPHIDs( 245 - $this->loadExcludeMailRecipientPHIDs()); 268 + $this->loadExcludeMailRecipientPHIDs()); 246 269 $handler->processEmail($this); 247 270 248 271 $this->setRelatedPHID($receiver->getPHID());
+13 -6
src/applications/people/storage/PhabricatorExternalAccount.php
··· 2 2 3 3 final class PhabricatorExternalAccount extends PhabricatorUserDAO { 4 4 5 - private $userPHID; 6 - private $accountType; 7 - private $accountDomain; 8 - private $accountSecret; 9 - private $accountID; 10 - private $displayName; 5 + protected $userPHID; 6 + protected $accountType; 7 + protected $accountDomain; 8 + protected $accountSecret; 9 + protected $accountID; 10 + protected $displayName; 11 11 12 12 public function generatePHID() { 13 13 return PhabricatorPHID::generateNewPHID( 14 14 PhabricatorPHIDConstants::PHID_TYPE_XUSR); 15 15 } 16 + 17 + public function getConfiguration() { 18 + return array( 19 + self::CONFIG_AUX_PHID => true, 20 + ) + parent::getConfiguration(); 21 + } 22 + 16 23 }