diff --git a/controllers/Controller.php b/controllers/Controller.php index 93e7361..af37e56 100644 --- a/controllers/Controller.php +++ b/controllers/Controller.php @@ -89,8 +89,32 @@ class Controller { return $response; } - public function webmention_details(Request $request, Response $response) { + public function webmention_details(Request $request, Response $response, $args) { + if(!$this->_is_logged_in($request, $response)) { + return $response; + } + + // Look up the webmention by its token + $webmention = ORM::for_table('webmentions')->where('token', $args['code'])->find_one(); + + if(!$webmention) { + $response->setContent(view('not-found')); + return $response; + } + $site = ORM::for_table('sites')->where_id_is($webmention->site_id)->find_one(); + + $statuses = ORM::for_table('webmention_status')->where('webmention_id', $webmention->id)->order_by_desc('created_at')->find_many(); + + $response->setContent(view('webmention-details', [ + 'title' => 'Webmention Details', + 'user' => $this->_user(), + 'accounts' => $this->_accounts(), + 'site' => $site, + 'webmention' => $webmention, + 'statuses' => $statuses + ])); + return $response; } private function _user() { diff --git a/lib/Telegraph/Webmention.php b/lib/Telegraph/Webmention.php index 0ec2dbc..392edb7 100644 --- a/lib/Telegraph/Webmention.php +++ b/lib/Telegraph/Webmention.php @@ -86,6 +86,9 @@ class Webmention { if(array_key_exists('Location', $response['headers'])) { $webmention->webmention_status_url = \Mf2\resolveUrl($endpoint, $response['headers']['Location']); // TODO: queue a job to poll the endpoint for updates and deliver to the callback URL + } else { + // No status URL was returned, so we can't follow up with this later. Mark as complete. + $webmention->complete = 1; } } else { diff --git a/views/dashboard.php b/views/dashboard.php index e630894..7b06f07 100644 --- a/views/dashboard.php +++ b/views/dashboard.php @@ -3,21 +3,23 @@
- + > + source=e($mention['webmention']->source) ?>
+ target=e($mention['webmention']->target) ?> + +
Status Date Source & Target
created_at)) ?> - source=e($mention['webmention']->source) ?>
- target=e($mention['webmention']->target) ?>
diff --git a/views/webmention-details.php b/views/webmention-details.php new file mode 100644 index 0000000..7b25c03 --- /dev/null +++ b/views/webmention-details.php @@ -0,0 +1,95 @@ +layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> + +
+ +

Webmention Request

+ + + + + + + + + + + + + + + vouch): ?> + + + + + + callback): ?> + + + + + +
Datecreated_at)) ?>
Sourcee($webmention->source) ?>
Targete($webmention->target) ?>
Vouche($webmention->vouch) ?>
Callback URLe($webmention->callback) ?>
+ +

Details

+ + +

The request is queued for processing. Check for updates again later.

+ + + + webmention_endpoint): ?> + + + + + + pingback_endpoint): ?> + + + + + + webmention_endpoint == false && $webmention->pingback_endpoint == false): ?> + + + + + + webmention_endpoint): ?> + + + + + +
Webmention Endpointe($webmention->webmention_endpoint) ?>
Pingback Endpointe($webmention->pingback_endpoint) ?>
Webmention EndpointNo webmention endpoint was discovered for this target
Status URLwebmention_status_url ? $this->e($webmention->webmention_status_url) : 'The webmention endpoint did not return a status URL' ?>
+ +

Logs

+ + + + + + + + + + + + + + + + + + + + + +
DateStatusHTTP Code
created_at)) ?>status ?>http_code ?>
+
e($status->raw_response) ?>
+
+ + + +