Skip to content

Conversation

@Akhill2020
Copy link
Contributor

@Akhill2020 Akhill2020 commented Dec 17, 2025

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

  • New Features
    • Added support for retrieving event cover images from OAuth-connected services in base64 format, enabling seamless integration of images with calendar events from connected accounts.

✏️ Tip: You can customize this high-level summary in your review settings.

@Akhill2020 Akhill2020 requested a review from rosinghal December 17, 2025 05:58
@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

A new public method auth_get_events_cover_base64image is added to handle retrieving event cover images as base64-encoded data. The implementation spans two classes: Auth_Service_Helpers registers a filter and delegates to Oauth_Ajax, which constructs and sends a request to a remote endpoint, then parses and returns the response.

Changes

Cohort / File(s) Summary
OAuth Event Cover Image Handler
includes/oauthhelper/class-oauth-service.php, includes/oauthhelper/oauth-service-actions.php
Adds new public method auth_get_events_cover_base64image($fileid, $args) across two classes. In Auth_Service_Helpers, the method instantiates Oauth_Ajax and delegates to its corresponding method. In Oauth_Ajax, the method constructs a request with site URL, auth token, fileid, and args, posts to remote endpoint, and returns parsed JSON response. Also registers a new filter simple_calendar_oauth_get_events_cover_base64image with priority 10 accepting 2 arguments.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Area of attention: The summary notes that auth_get_events_cover_base64image in oauth-service-actions.php appears to be added twice (duplicate declarations)—verify this is intentional or resolve the duplication before merge.
  • Area of attention: Error handling logic in Oauth_Ajax method should be validated to ensure all response scenarios (success, error message, network failure) are properly handled and documented.

Suggested reviewers

  • rosinghal

Poem

🐰 A cover image fair, encoded to base64,
Through OAuth filters and helpers it'll soar,
To Ajax it hops, to endpoints remote,
Base images now float, without a care note!
nibbles carrot proudly 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly references fixing a cover image display issue, which matches the PR's primary objective of resolving the cover image not displaying problem.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-cover-image-not-display

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 for wp_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_Ajax and follows the established pattern. However, the @since 1.0.0 tag 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

📥 Commits

Reviewing files that changed from the base of the PR and between bb600c4 and 0ea701a.

📒 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.

Comment on lines +254 to +288
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;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants