diff --git a/controller/action/AcquisitionActions.class.php b/controller/action/AcquisitionActions.class.php index 986eed05..49a9629f 100644 --- a/controller/action/AcquisitionActions.class.php +++ b/controller/action/AcquisitionActions.class.php @@ -5,13 +5,15 @@ class AcquisitionActions extends Actions public static function executeYouTube(string $version = '') { $errorMessage = Request::getParam('error_message', ''); + if (Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR)) { $errorMessage = Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR); } + return ['acquisition/youtube', [ - 'reward' => LBRY::youtubeReward(), - 'error_message' => $errorMessage - ]]; + 'reward' => LBRY::youtubeReward(), + 'error_message' => $errorMessage + ]]; } public static function executeVerify(string $token) @@ -33,6 +35,7 @@ class AcquisitionActions extends Actions } $token = LBRY::connectYoutube($channelName); + if ($token['success'] && $token['data']) { Controller::redirect($token['data']); } else { @@ -44,16 +47,17 @@ class AcquisitionActions extends Actions public static function executeYoutubeStatus(string $token) { $data = LBRY::statusYoutube($token); + if (!$data['success']) { Session::setFlash(Session::KEY_YOUTUBE_SYNC_ERROR, $data['error'] ?? "Error fetching your sync status."); Controller::redirect('/youtube'); } return ['acquisition/youtube_status', [ - 'token' => $token, - 'status_token' => $data, - 'error_message' => Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR) - ]]; + 'token' => $token, + 'status_token' => $data, + 'error_message' => Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR) + ]]; } public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent) @@ -72,6 +76,7 @@ class AcquisitionActions extends Actions Controller::redirect("/youtube/status/" . $status_token); } } + public static function executeYoutubeEdit() { return ['acquisition/youtube_edit']; diff --git a/lib/thirdparty/LBRY.class.php b/lib/thirdparty/LBRY.class.php index 1df5d1c0..6b4636a1 100644 --- a/lib/thirdparty/LBRY.class.php +++ b/lib/thirdparty/LBRY.class.php @@ -58,7 +58,14 @@ class LBRY return Curl::post(static::getApiUrl('/yt/new'), ['desired_lbry_channel_name' => $channel_name, 'type' => $type], ['json_response' => true]); // Uncomment next line for development and comment other return (this also requires the testnet API) - // return Curl::post(static::getApiUrl('/yt/new'), ['desired_lbry_channel_name' => $channel_name, 'type' => $type, 'return_url' => 'http://localhost:8000/youtube/status/'], ['json_response' => true]); + // return Curl::post(static::getApiUrl('/yt/new'), [ + // 'desired_lbry_channel_name' => $channel_name, + // 'immediate_sync' => true, + // 'return_url' => 'http://localhost:8000/youtube/status/', + // 'type' => $type + // ], [ + // 'json_response' => true + // ]); } // Check the sync status diff --git a/view/template/acquisition/youtube.php b/view/template/acquisition/youtube.php index af8635e1..88ca2049 100644 --- a/view/template/acquisition/youtube.php +++ b/view/template/acquisition/youtube.php @@ -47,6 +47,8 @@ if ($error_message): echo "
" . "The following error occurred: ". $error_message . " For support please send an email to hello@lbry.com." . "
"; endif;?> +LBRY channel name is either not valid or your input is blank
+