1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +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:
Zedstar 2013-04-28 13:22:05 -07:00 committed by epriestley
parent 09ed95583c
commit f53cde8f92
4 changed files with 64 additions and 24 deletions

View file

@ -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.

View file

@ -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.')),
);
}

View file

@ -211,29 +211,52 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
if ($user) {
$this->setAuthorPHID($user->getPHID());
} else {
$default_author = PhabricatorEnv::getEnvConfig(
'metamta.maniphest.default-public-author');
$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();
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 {
// 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();
$default_author = PhabricatorEnv::getEnvConfig(
'metamta.maniphest.default-public-author');
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->setOriginalEmailSource($from);
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
$editor = new ManiphestTransactionEditor();
@ -242,7 +265,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
$handler->setActor($user);
$handler->setExcludeMailRecipientPHIDs(
$this->loadExcludeMailRecipientPHIDs());
$this->loadExcludeMailRecipientPHIDs());
$handler->processEmail($this);
$this->setRelatedPHID($receiver->getPHID());

View file

@ -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();
}
}