Changeset View
Changeset View
Standalone View
Standalone View
src/applications/doorkeeper/worker/DoorkeeperAsanaFeedWorker.php
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | protected function publishFeedStory() { | ||||
// For each user that we don't have a subtask for, create a new subtask. | // For each user that we don't have a subtask for, create a new subtask. | ||||
foreach ($need_subtasks as $user_phid => $is_completed) { | foreach ($need_subtasks as $user_phid => $is_completed) { | ||||
$subtask = $this->makeAsanaAPICall( | $subtask = $this->makeAsanaAPICall( | ||||
$oauth_token, | $oauth_token, | ||||
'tasks', | 'tasks', | ||||
'POST', | 'POST', | ||||
$subtask_data + array( | $subtask_data + array( | ||||
'assignee' => $phid_aid_map[$user_phid], | 'assignee' => $phid_aid_map[$user_phid], | ||||
'completed' => $is_completed, | 'completed' => (int)$is_completed, | ||||
'parent' => $parent_ref->getObjectID(), | 'parent' => $parent_ref->getObjectID(), | ||||
)); | )); | ||||
$subtask_ref = $this->newRefFromResult( | $subtask_ref = $this->newRefFromResult( | ||||
DoorkeeperBridgeAsana::OBJTYPE_TASK, | DoorkeeperBridgeAsana::OBJTYPE_TASK, | ||||
$subtask); | $subtask); | ||||
$user_to_ref_map[$user_phid] = $subtask_ref; | $user_to_ref_map[$user_phid] = $subtask_ref; | ||||
Show All 18 Lines | protected function publishFeedStory() { | ||||
foreach ($subtask_states as $user_phid => $is_completed) { | foreach ($subtask_states as $user_phid => $is_completed) { | ||||
$this->makeAsanaAPICall( | $this->makeAsanaAPICall( | ||||
$oauth_token, | $oauth_token, | ||||
'tasks/'.$user_to_ref_map[$user_phid]->getObjectID(), | 'tasks/'.$user_to_ref_map[$user_phid]->getObjectID(), | ||||
'PUT', | 'PUT', | ||||
$subtask_data + array( | $subtask_data + array( | ||||
'assignee' => $phid_aid_map[$user_phid], | 'assignee' => $phid_aid_map[$user_phid], | ||||
'completed' => $is_completed, | 'completed' => (int)$is_completed, | ||||
)); | )); | ||||
} | } | ||||
foreach ($user_to_ref_map as $user_phid => $ref) { | foreach ($user_to_ref_map as $user_phid => $ref) { | ||||
// For each subtask, if the acting user isn't the same user as the subtask | // For each subtask, if the acting user isn't the same user as the subtask | ||||
// owner, remove the acting user as a follower. Currently, the acting user | // owner, remove the acting user as a follower. Currently, the acting user | ||||
// will be added as a follower only when they create the task, but this | // will be added as a follower only when they create the task, but this | ||||
// may change in the future (e.g., closing the task may also mark them | // may change in the future (e.g., closing the task may also mark them | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | $notes = array( | ||||
$this->getSynchronizationWarning(), | $this->getSynchronizationWarning(), | ||||
); | ); | ||||
$notes = implode("\n\n", $notes); | $notes = implode("\n\n", $notes); | ||||
return array( | return array( | ||||
'name' => $title, | 'name' => $title, | ||||
'notes' => $notes, | 'notes' => $notes, | ||||
'completed' => $is_completed, | 'completed' => (int)$is_completed, | ||||
); | ); | ||||
} | } | ||||
private function getAsanaSubtaskData($object) { | private function getAsanaSubtaskData($object) { | ||||
$publisher = $this->getPublisher(); | $publisher = $this->getPublisher(); | ||||
$title = $publisher->getResponsibilityTitle($object); | $title = $publisher->getResponsibilityTitle($object); | ||||
$uri = $publisher->getObjectURI($object); | $uri = $publisher->getObjectURI($object); | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | return id(new PhutilAsanaFuture()) | ||||
->resolve(); | ->resolve(); | ||||
} | } | ||||
private function newRefFromResult($type, $result) { | private function newRefFromResult($type, $result) { | ||||
$ref = id(new DoorkeeperObjectRef()) | $ref = id(new DoorkeeperObjectRef()) | ||||
->setApplicationType(DoorkeeperBridgeAsana::APPTYPE_ASANA) | ->setApplicationType(DoorkeeperBridgeAsana::APPTYPE_ASANA) | ||||
->setApplicationDomain(DoorkeeperBridgeAsana::APPDOMAIN_ASANA) | ->setApplicationDomain(DoorkeeperBridgeAsana::APPDOMAIN_ASANA) | ||||
->setObjectType($type) | ->setObjectType($type) | ||||
->setObjectID($result['id']) | ->setObjectID($result['gid']) | ||||
->setIsVisible(true); | ->setIsVisible(true); | ||||
$xobj = $ref->newExternalObject(); | $xobj = $ref->newExternalObject(); | ||||
$ref->attachExternalObject($xobj); | $ref->attachExternalObject($xobj); | ||||
$bridge = new DoorkeeperBridgeAsana(); | $bridge = new DoorkeeperBridgeAsana(); | ||||
$bridge->fillObjectFromData($xobj, $result); | $bridge->fillObjectFromData($xobj, $result); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |