-
Notifications
You must be signed in to change notification settings - Fork 39
fix cover image not display issue #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new public method Changes
Sequence DiagramsequenceDiagram
participant Filter as Filter System
participant Helper as Auth_Service_Helpers
participant Ajax as Oauth_Ajax
participant Remote as Remote Endpoint
Filter->>Helper: simple_calendar_oauth_get_events_cover_base64image<br/>(fileid, args)
Helper->>Helper: Instantiate Oauth_Ajax
Helper->>Ajax: auth_get_events_cover_base64image(fileid, args)
Ajax->>Ajax: Construct payload<br/>(site_url, auth_token, fileid, args)
Ajax->>Remote: POST to auth_get_events_cover_base64image
Remote-->>Ajax: JSON response
Ajax->>Ajax: Parse response
alt Response is true
Ajax-->>Helper: Return full response
else Message provided
Ajax-->>Helper: Return error array with message
else Neither condition
Ajax-->>Helper: Return network issue error
end
Helper-->>Filter: Return result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
includes/oauthhelper/oauth-service-actions.php (1)
262-267: Consider adding error handling for failed HTTP requests.Similar to
oauth_deauthenticate_site(line 76), consider checking forwp_is_error()or non-200 response codes to handle network failures more gracefully.Example:
$request = wp_remote_post(self::$url . 'auth_get_events_cover_base64image', [ 'method' => 'POST', 'body' => $send_data, 'timeout' => 30, 'cookies' => [], ]); + + if (is_wp_error($request) || wp_remote_retrieve_response_code($request) != 200) { + error_log(print_r($request, true)); + } $response = wp_remote_retrieve_body($request);includes/oauthhelper/class-oauth-service.php (1)
165-179: Consider updating the @SInCE version.The method implementation correctly delegates to
Oauth_Ajaxand follows the established pattern. However, the@since 1.0.0tag appears incorrect for a newly added method./** * Get events cover base64 image. * - * @since 1.0.0 + * @since 3.4.2 * * @param string $fileid * @param array $args * @return array */Note: Adjust the version number to match your current release version.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
includes/oauthhelper/class-oauth-service.php(2 hunks)includes/oauthhelper/oauth-service-actions.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
includes/oauthhelper/class-oauth-service.php (1)
includes/oauthhelper/oauth-service-actions.php (2)
auth_get_events_cover_base64image(254-288)Oauth_Ajax(18-289)
includes/oauthhelper/oauth-service-actions.php (1)
includes/oauthhelper/class-oauth-service.php (1)
auth_get_events_cover_base64image(174-179)
🔇 Additional comments (1)
includes/oauthhelper/class-oauth-service.php (1)
33-38: LGTM!The filter registration follows the established pattern and correctly hooks into the new method with appropriate priority and argument count.
| public function auth_get_events_cover_base64image($fileid, $args) | ||
| { | ||
| $send_data = [ | ||
| 'site_url' => self::$my_site_url, | ||
| 'auth_token' => get_option('simple_calendar_auth_site_token'), | ||
| 'fileid' => $fileid, | ||
| 'arguments' => $args, | ||
| ]; | ||
| $request = wp_remote_post(self::$url . 'auth_get_events_cover_base64image', [ | ||
| 'method' => 'POST', | ||
| 'body' => $send_data, | ||
| 'timeout' => 30, | ||
| 'cookies' => [], | ||
| ]); | ||
|
|
||
| $response = wp_remote_retrieve_body($request); | ||
| $response_arr = json_decode($response, true); | ||
|
|
||
| if (isset($response_arr['response']) && !empty($response_arr['response'])) { | ||
| if ($response_arr['response']) { | ||
| return $response_arr; | ||
| } | ||
| } elseif (isset($response_arr['message']) && !empty($response_arr['message'])) { | ||
| $response = [ | ||
| 'Error' => $response_arr['message'], | ||
| ]; | ||
| return $response; | ||
| } else { | ||
| $response = [ | ||
| 'response' => false, | ||
| 'message' => __('Network issue.', 'google-calendar-events'), | ||
| ]; | ||
| return $response; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent error response structure in network error case.
The network error response structure differs from similar methods in this class. Line 282-286 returns ['response' => false, 'message' => ...], while auth_get_calendarsevents (line 201-204) returns ['Error' => ...] for the same scenario. This inconsistency complicates error handling for callers.
Apply this diff to align with the existing pattern:
} else {
$response = [
- 'response' => false,
- 'message' => __('Network issue.', 'google-calendar-events'),
+ 'Error' => __('Network issue.', 'google-calendar-events'),
];
return $response;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public function auth_get_events_cover_base64image($fileid, $args) | |
| { | |
| $send_data = [ | |
| 'site_url' => self::$my_site_url, | |
| 'auth_token' => get_option('simple_calendar_auth_site_token'), | |
| 'fileid' => $fileid, | |
| 'arguments' => $args, | |
| ]; | |
| $request = wp_remote_post(self::$url . 'auth_get_events_cover_base64image', [ | |
| 'method' => 'POST', | |
| 'body' => $send_data, | |
| 'timeout' => 30, | |
| 'cookies' => [], | |
| ]); | |
| $response = wp_remote_retrieve_body($request); | |
| $response_arr = json_decode($response, true); | |
| if (isset($response_arr['response']) && !empty($response_arr['response'])) { | |
| if ($response_arr['response']) { | |
| return $response_arr; | |
| } | |
| } elseif (isset($response_arr['message']) && !empty($response_arr['message'])) { | |
| $response = [ | |
| 'Error' => $response_arr['message'], | |
| ]; | |
| return $response; | |
| } else { | |
| $response = [ | |
| 'response' => false, | |
| 'message' => __('Network issue.', 'google-calendar-events'), | |
| ]; | |
| return $response; | |
| } | |
| } | |
| public function auth_get_events_cover_base64image($fileid, $args) | |
| { | |
| $send_data = [ | |
| 'site_url' => self::$my_site_url, | |
| 'auth_token' => get_option('simple_calendar_auth_site_token'), | |
| 'fileid' => $fileid, | |
| 'arguments' => $args, | |
| ]; | |
| $request = wp_remote_post(self::$url . 'auth_get_events_cover_base64image', [ | |
| 'method' => 'POST', | |
| 'body' => $send_data, | |
| 'timeout' => 30, | |
| 'cookies' => [], | |
| ]); | |
| $response = wp_remote_retrieve_body($request); | |
| $response_arr = json_decode($response, true); | |
| if (isset($response_arr['response']) && !empty($response_arr['response'])) { | |
| if ($response_arr['response']) { | |
| return $response_arr; | |
| } | |
| } elseif (isset($response_arr['message']) && !empty($response_arr['message'])) { | |
| $response = [ | |
| 'Error' => $response_arr['message'], | |
| ]; | |
| return $response; | |
| } else { | |
| $response = [ | |
| 'Error' => __('Network issue.', 'google-calendar-events'), | |
| ]; | |
| return $response; | |
| } | |
| } |
🤖 Prompt for AI Agents
In includes/oauthhelper/oauth-service-actions.php around lines 254 to 288, the
network-error branch returns an object with keys ['response' => false, 'message'
=> ...] which is inconsistent with other methods (e.g. auth_get_calendarsevents)
that return ['Error' => ...]; change the final else branch to return an array
with a single 'Error' key containing the __('Network issue.',
'google-calendar-events') message so callers receive the same error structure as
other methods.
Description: There is an issue with cover image due to some google drive class object not found, I have update cover image endpoint and get bas64image from auth site because we dont create object of drive class on the users site. Add calback function for register page template.
Before & After: https://drive.google.com/file/d/14uGW01Uy5D6L2t4Z8oDtg7qv1MkjnSTM/view?usp=drivesdk
Clickup: https://app.clickup.com/t/86d1act7j
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.