mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Update Asana feed publishing integration for "ExternalAccountIdentifier"
Summary: Depends on D21017. Ref T13493. Update the Asana integration so it reads the "ExternalAccountIdentifier" table instead of the old "accountID" field. Test Plan: Linked an Asana account, used `bin/feed republish` to publish activity to Asana. Maniphest Tasks: T13493 Differential Revision: https://secure.phabricator.com/D21018
This commit is contained in:
parent
faf9f06e0a
commit
b8f0613b30
1 changed files with 20 additions and 2 deletions
|
@ -532,6 +532,7 @@ final class DoorkeeperAsanaFeedWorker extends DoorkeeperFeedWorker {
|
|||
->withUserPHIDs($all_phids)
|
||||
->withAccountTypes(array($provider->getProviderType()))
|
||||
->withAccountDomains(array($provider->getProviderDomain()))
|
||||
->needAccountIdentifiers(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
|
@ -540,7 +541,7 @@ final class DoorkeeperAsanaFeedWorker extends DoorkeeperFeedWorker {
|
|||
->execute();
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$phid_map[$account->getUserPHID()] = $account->getAccountID();
|
||||
$phid_map[$account->getUserPHID()] = $this->getAsanaAccountID($account);
|
||||
}
|
||||
|
||||
// Put this back in input order.
|
||||
|
@ -562,6 +563,7 @@ final class DoorkeeperAsanaFeedWorker extends DoorkeeperFeedWorker {
|
|||
->withUserPHIDs($user_phids)
|
||||
->withAccountTypes(array($provider->getProviderType()))
|
||||
->withAccountDomains(array($provider->getProviderDomain()))
|
||||
->needAccountIdentifiers(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
|
@ -601,7 +603,7 @@ final class DoorkeeperAsanaFeedWorker extends DoorkeeperFeedWorker {
|
|||
->withPHIDs(array($account->getUserPHID()))
|
||||
->executeOne();
|
||||
if ($user) {
|
||||
return array($user, $account->getAccountID(), $token);
|
||||
return array($user, $this->getAsanaAccountID($account), $token);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -706,4 +708,20 @@ final class DoorkeeperAsanaFeedWorker extends DoorkeeperFeedWorker {
|
|||
}
|
||||
}
|
||||
|
||||
private function getAsanaAccountID(PhabricatorExternalAccount $account) {
|
||||
$identifiers = $account->getAccountIdentifiers();
|
||||
|
||||
if (count($identifiers) !== 1) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Expected external Asana account to have exactly one external '.
|
||||
'account identifier, found %s.',
|
||||
phutil_count($identifiers)));
|
||||
}
|
||||
|
||||
return head($identifiers)->getIdentifierRaw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue