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.
|
||||
'metamta.vary-subjects' => true,
|
||||
|
||||
|
||||
// -- Auth ------------------------------------------------------------------ //
|
||||
|
||||
// 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
|
||||
'phabricator.uninstalled-applications' => array(),
|
||||
|
||||
// Allowing non-members to interact with tasks over email.
|
||||
'phabricator.allow-email-users' => false,
|
||||
|
||||
// -- 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)
|
||||
->setLocked(true)
|
||||
->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();
|
||||
if ($user) {
|
||||
$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 {
|
||||
$default_author = PhabricatorEnv::getEnvConfig(
|
||||
'metamta.maniphest.default-public-author');
|
||||
|
@ -218,14 +238,14 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'username = %s',
|
||||
$default_author);
|
||||
if ($user) {
|
||||
$receiver->setOriginalEmailSource($from);
|
||||
} else {
|
||||
|
||||
if (!$user) {
|
||||
throw new Exception(
|
||||
"Phabricator is misconfigured, the configuration key ".
|
||||
"'metamta.maniphest.default-public-author' is set to user ".
|
||||
"'{$default_author}' but that user does not exist.");
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: We should probably bounce these since from the user's
|
||||
// perspective their email vanishes into a black hole.
|
||||
|
@ -233,7 +253,10 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$receiver->setAuthorPHID($user->getPHID());
|
||||
$receiver->setOriginalEmailSource($from);
|
||||
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||
|
||||
$editor = new ManiphestTransactionEditor();
|
||||
|
|
|
@ -2,15 +2,22 @@
|
|||
|
||||
final class PhabricatorExternalAccount extends PhabricatorUserDAO {
|
||||
|
||||
private $userPHID;
|
||||
private $accountType;
|
||||
private $accountDomain;
|
||||
private $accountSecret;
|
||||
private $accountID;
|
||||
private $displayName;
|
||||
protected $userPHID;
|
||||
protected $accountType;
|
||||
protected $accountDomain;
|
||||
protected $accountSecret;
|
||||
protected $accountID;
|
||||
protected $displayName;
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_XUSR);
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue