Skip to content

Commit

Permalink
Fix: overload on server
Browse files Browse the repository at this point in the history
  • Loading branch information
Niloys7 committed Dec 21, 2022
1 parent d6c92a8 commit 11e80dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions class-remote-notification-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ protected function get_remote_url( $url ) {
* @return string|WP_Error
*/
protected function remote_get_notification( $notification ) {
if ( get_transient( 'wpi_check_ran_' . $notification['notice_id'] ) ) {
return new WP_Error( 'transient_response', __( 'Can\'t run before the transient expired', 'remote-notifications' ) );
}

set_transient( 'wpi_check_ran_' . $notification['notice_id'], 1, 3 * HOUR_IN_SECONDS );
/* Query the server */
$response = wp_remote_get( $this->build_query_url( $notification['server_url'], $this->get_payload( $notification ) ), array( 'timeout' => apply_filters( 'rn_http_request_timeout', 5 ) ) );

Expand All @@ -683,8 +687,7 @@ protected function remote_get_notification( $notification ) {
$body = json_decode( $body );

if ( is_null( $body ) ) {



return new WP_Error( 'json_decode_error', __( 'Cannot decode the response content', 'remote-notifications' ) );
}

Expand Down

0 comments on commit 11e80dd

Please sign in to comment.