has('target') !== true) || ($request->has('source') !== true)) { return response( 'You need both the target and source parameters', 400 ); } // next check the $target is valid $path = parse_url($request->input('target'), PHP_URL_PATH); $pathParts = explode('/', $path); if ($pathParts[1] === 'notes') { // we have a note $noteId = $pathParts[2]; try { $note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId)); dispatch(new ProcessWebMention($note, $request->input('source'))); } catch (ModelNotFoundException $e) { return response('This note doesn’t exist.', 400); } return response( 'Webmention received, it will be processed shortly', 202 ); } if ($pathParts[1] === 'blog') { return response( 'I don’t accept webmentions for blog posts yet.', 501 ); } return response( 'Invalid request', 400 ); } }