mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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.')),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,29 +211,52 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->setAuthorPHID($user->getPHID());
|
$this->setAuthorPHID($user->getPHID());
|
||||||
} else {
|
} else {
|
||||||
$default_author = PhabricatorEnv::getEnvConfig(
|
$allow_email_users = PhabricatorEnv::getEnvConfig(
|
||||||
'metamta.maniphest.default-public-author');
|
'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();
|
||||||
|
|
||||||
if ($default_author) {
|
|
||||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
|
||||||
'username = %s',
|
|
||||||
$default_author);
|
|
||||||
if ($user) {
|
|
||||||
$receiver->setOriginalEmailSource($from);
|
|
||||||
} else {
|
|
||||||
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 {
|
} else {
|
||||||
// TODO: We should probably bounce these since from the user's
|
$default_author = PhabricatorEnv::getEnvConfig(
|
||||||
// perspective their email vanishes into a black hole.
|
'metamta.maniphest.default-public-author');
|
||||||
return $this->setMessage("Invalid public user '{$from}'.")->save();
|
|
||||||
|
if ($default_author) {
|
||||||
|
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||||
|
'username = %s',
|
||||||
|
$default_author);
|
||||||
|
|
||||||
|
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.
|
||||||
|
return $this->setMessage("Invalid public user '{$from}'.")->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$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();
|
||||||
|
@ -242,7 +265,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
|
|
||||||
$handler->setActor($user);
|
$handler->setActor($user);
|
||||||
$handler->setExcludeMailRecipientPHIDs(
|
$handler->setExcludeMailRecipientPHIDs(
|
||||||
$this->loadExcludeMailRecipientPHIDs());
|
$this->loadExcludeMailRecipientPHIDs());
|
||||||
$handler->processEmail($this);
|
$handler->processEmail($this);
|
||||||
|
|
||||||
$this->setRelatedPHID($receiver->getPHID());
|
$this->setRelatedPHID($receiver->getPHID());
|
||||||
|
|
|
@ -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