mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 17:02:41 +01:00
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
This commit is contained in:
parent
09ed95583c
commit
f53cde8f92
4 changed files with 64 additions and 24 deletions
|
@ -547,7 +547,6 @@ return array(
|
||||||
// preferences.
|
// preferences.
|
||||||
'metamta.vary-subjects' => true,
|
'metamta.vary-subjects' => true,
|
||||||
|
|
||||||
|
|
||||||
// -- Auth ------------------------------------------------------------------ //
|
// -- Auth ------------------------------------------------------------------ //
|
||||||
|
|
||||||
// Can users login with a username/password, or by following the link from
|
// Can users login with a username/password, or by following the link from
|
||||||
|
@ -850,6 +849,9 @@ return array(
|
||||||
// Contains a list of uninstalled applications
|
// Contains a list of uninstalled applications
|
||||||
'phabricator.uninstalled-applications' => array(),
|
'phabricator.uninstalled-applications' => array(),
|
||||||
|
|
||||||
|
// Allowing non-members to interact with tasks over email.
|
||||||
|
'phabricator.allow-email-users' => false,
|
||||||
|
|
||||||
// -- Welcome Screen -------------------------------------------------------- //
|
// -- Welcome Screen -------------------------------------------------------- //
|
||||||
|
|
||||||
// The custom HTML content for the Phabricator welcome screen.
|
// The custom HTML content for the Phabricator welcome screen.
|
||||||
|
|
|
@ -153,6 +153,14 @@ final class PhabricatorCoreConfigOptions
|
||||||
$this->newOption('phabricator.cache-namespace', 'string', null)
|
$this->newOption('phabricator.cache-namespace', 'string', null)
|
||||||
->setLocked(true)
|
->setLocked(true)
|
||||||
->setDescription(pht('Cache namespace.')),
|
->setDescription(pht('Cache namespace.')),
|
||||||
|
$this->newOption('phabricator.allow-email-users', 'bool', false)
|
||||||
|
->setBoolOptions(
|
||||||
|
array(
|
||||||
|
pht('Allow'),
|
||||||
|
pht('Disallow'),
|
||||||
|
))->setDescription(
|
||||||
|
pht(
|
||||||
|
'Allow non-members to interact with tasks over email.')),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,26 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
$user = $this->lookupSender();
|
$user = $this->lookupSender();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->setAuthorPHID($user->getPHID());
|
$this->setAuthorPHID($user->getPHID());
|
||||||
|
} else {
|
||||||
|
$allow_email_users = PhabricatorEnv::getEnvConfig(
|
||||||
|
'phabricator.allow-email-users');
|
||||||
|
|
||||||
|
if ($allow_email_users) {
|
||||||
|
$email = new PhutilEmailAddress($from);
|
||||||
|
|
||||||
|
$user = id(new PhabricatorExternalAccount())->loadOneWhere(
|
||||||
|
'accountType = %s AND accountDomain IS NULL and accountID = %s',
|
||||||
|
'email', $email->getAddress());
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
$user = new PhabricatorExternalAccount();
|
||||||
|
$user->setAccountID($email->getAddress());
|
||||||
|
$user->setAccountType('email');
|
||||||
|
$user->setDisplayName($email->getDisplayName());
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$default_author = PhabricatorEnv::getEnvConfig(
|
$default_author = PhabricatorEnv::getEnvConfig(
|
||||||
'metamta.maniphest.default-public-author');
|
'metamta.maniphest.default-public-author');
|
||||||
|
@ -218,14 +238,14 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||||
'username = %s',
|
'username = %s',
|
||||||
$default_author);
|
$default_author);
|
||||||
if ($user) {
|
|
||||||
$receiver->setOriginalEmailSource($from);
|
if (!$user) {
|
||||||
} else {
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"Phabricator is misconfigured, the configuration key ".
|
"Phabricator is misconfigured, the configuration key ".
|
||||||
"'metamta.maniphest.default-public-author' is set to user ".
|
"'metamta.maniphest.default-public-author' is set to user ".
|
||||||
"'{$default_author}' but that user does not exist.");
|
"'{$default_author}' but that user does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: We should probably bounce these since from the user's
|
// TODO: We should probably bounce these since from the user's
|
||||||
// perspective their email vanishes into a black hole.
|
// perspective their email vanishes into a black hole.
|
||||||
|
@ -233,7 +253,10 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$receiver->setAuthorPHID($user->getPHID());
|
$receiver->setAuthorPHID($user->getPHID());
|
||||||
|
$receiver->setOriginalEmailSource($from);
|
||||||
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||||
|
|
||||||
$editor = new ManiphestTransactionEditor();
|
$editor = new ManiphestTransactionEditor();
|
||||||
|
|
|
@ -2,15 +2,22 @@
|
||||||
|
|
||||||
final class PhabricatorExternalAccount extends PhabricatorUserDAO {
|
final class PhabricatorExternalAccount extends PhabricatorUserDAO {
|
||||||
|
|
||||||
private $userPHID;
|
protected $userPHID;
|
||||||
private $accountType;
|
protected $accountType;
|
||||||
private $accountDomain;
|
protected $accountDomain;
|
||||||
private $accountSecret;
|
protected $accountSecret;
|
||||||
private $accountID;
|
protected $accountID;
|
||||||
private $displayName;
|
protected $displayName;
|
||||||
|
|
||||||
public function generatePHID() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorPHID::generateNewPHID(
|
||||||
PhabricatorPHIDConstants::PHID_TYPE_XUSR);
|
PhabricatorPHIDConstants::PHID_TYPE_XUSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfiguration() {
|
||||||
|
return array(
|
||||||
|
self::CONFIG_AUX_PHID => true,
|
||||||
|
) + parent::getConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue