X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FRepoHook.php;h=14d3d69da48fa20e0b13b40f613f7e9938532009;hb=ee3977104c9ea0984c76f75f965c528bc4b3b64e;hp=6733b3f680e6b3cc247a048b14d4fc0bb41168a9;hpb=a2af03951ac7fbd032609d0044c0a85704b77771;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/RepoHook.php b/app/Controller/Github/RepoHook.php index 6733b3f..14d3d69 100644 --- a/app/Controller/Github/RepoHook.php +++ b/app/Controller/Github/RepoHook.php @@ -3,6 +3,7 @@ namespace app\Controller\Github; use app\Controller\Github; +use app\Github\API\Hooks\ListHooks; class RepoHook extends Github { @@ -34,43 +35,52 @@ class RepoHook extends Github function addHook($owner, $repo) { $hook_conf = $this->app->getRequest()->getForm(); - $call = $this->github->createRepoHook("$owner/$repo", $hook_conf, function($hook) use($owner, $repo, &$call) { - $call->dropFromCache(); - $this->redirectBack("$owner/$repo"); + $this->github->createRepoHook("$owner/$repo", $hook_conf)->then(function($hook) use($owner, $repo) { + $call = new ListHooks($this->github, ["repo" => "$owner/$repo", "fresh" => true]); + $this->github->queue($call)->then(function() use($owner, $repo) { + $this->redirectBack("$owner/$repo"); + }); }); - $call->send(); + $this->github->drain(); } function updateHook($owner, $repo) { - $this->github->fetchRepo("$owner/$repo", function($repo) { - $call = $this->github->fetchHooks($repo->full_name, function($hooks, $links) use($repo, &$call) { - $repo->hooks = $hooks; - if (($hook = $this->checkRepoHook($repo))) { + $this->github->readRepo("$owner/$repo")->then(function($result) { + list($repo) = $result; + $call = new ListHooks($this->github, ["repo" => $repo->full_name]); + $this->github->queue($call)->then(function($result) use($repo, $call) { + list($repo->hooks) = $result; + if (($hook = $this->github->checkRepoHook($repo))) { $hook_conf = $this->app->getRequest()->getForm(); - $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf, function($changed_hook) use($repo, $hook, $hooks, $links, $call) { + $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf)->then(function($hook_result) use($repo, $hook, $result, $call) { + list($changed_hook) = $hook_result; foreach ($changed_hook as $key => $val) { $hook->$key = $val; } - $call->saveToCache([$hooks, $links]); + $call->saveToCache($result); $this->redirectBack($repo->full_name); }); } }); - })->send(); + }); + $this->github->drain(); } function delHook($owner, $repo) { - $this->github->fetchRepo("$owner/$repo", function($repo) { - $call = $this->github->fetchHooks($repo->full_name, function($hooks) use($repo, &$call) { - $repo->hooks = $hooks; - if (($hook = $this->checkRepoHook($repo))) { - $this->github->deleteRepoHook($repo->full_name, $hook->id, function() use($repo, $call) { + $this->github->readRepo("$owner/$repo")->then(function($result) { + list($repo) = $result; + $call = new ListHooks($this->github, ["repo" => $repo->full_name]); + $this->github->queue($call)->then(function($result) use($repo, $call) { + list($repo->hooks) = $result; + if (($hook = $this->github->checkRepoHook($repo))) { + $this->github->deleteRepoHook($repo->full_name, $hook->id)->then(function() use($repo, $call) { $call->dropFromCache(); $this->redirectBack($repo->full_name); }); } }); - })->send(); + }); + $this->github->drain(); } function redirectBack($repo) {