Skip to content

Commit

Permalink
Social: Remove deprecated dismiss notice endpoint (#41987)
Browse files Browse the repository at this point in the history
* Remove deprecated endpoint + functions

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/13498405524

Upstream-Ref: Automattic/jetpack@8c1204a
  • Loading branch information
gmjuhasz authored and matticbot committed Feb 24, 2025
1 parent 83e9fd6 commit 7f89780
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 161 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"automattic/jetpack-autoloader": "^5.0.1",
"automattic/jetpack-composer-plugin": "^4.0.0",
"automattic/jetpack-config": "^3.0.0",
"automattic/jetpack-publicize": "^0.60.2-alpha",
"automattic/jetpack-publicize": "^0.61.0-alpha",
"automattic/jetpack-connection": "^6.6.0-alpha",
"automattic/jetpack-my-jetpack": "^5.5.0-alpha",
"automattic/jetpack-sync": "^4.8.2-alpha",
Expand Down
7 changes: 5 additions & 2 deletions jetpack_vendor/automattic/jetpack-publicize/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.60.2-alpha] - unreleased
## [0.61.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

Expand All @@ -18,6 +18,9 @@ This is an alpha version! The changes listed here are not final.
- Updated the connections schema for classic editor
- Update Keyring_Helper class and enable publicize services caching

### Removed
- Removed the deprecated dismiss notice functionality

### Fixed
- Code: Prevent dynamic class properties.
- Fixed social connection toggle not working
Expand Down Expand Up @@ -877,7 +880,7 @@ This is an alpha version! The changes listed here are not final.
- Updated package dependencies.
- Update package.json metadata.

[0.60.2-alpha]: https://github.com/Automattic/jetpack-publicize/compare/v0.60.1...v0.60.2-alpha
[0.61.0-alpha]: https://github.com/Automattic/jetpack-publicize/compare/v0.60.1...v0.61.0-alpha
[0.60.1]: https://github.com/Automattic/jetpack-publicize/compare/v0.60.0...v0.60.1
[0.60.0]: https://github.com/Automattic/jetpack-publicize/compare/v0.59.1...v0.60.0
[0.59.1]: https://github.com/Automattic/jetpack-publicize/compare/v0.59.0...v0.59.1
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-publicize/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"link-template": "https://github.com/Automattic/jetpack-publicize/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "0.60.x-dev"
"dev-trunk": "0.61.x-dev"
}
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ public function register_rest_routes() {
)
);

// Dismiss a notice.
// Flagged to be removed after deprecation.
// @deprecated 0.47.2
register_rest_route(
'jetpack/v4',
'/social/dismiss-notice',
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'update_dismissed_notices' ),
'permission_callback' => array( $this, 'require_author_privilege_callback' ),
'args' => rest_get_endpoint_args_for_schema( $this->get_dismiss_notice_endpoint_schema(), WP_REST_Server::CREATABLE ),
'schema' => array( $this, 'get_dismiss_notice_endpoint_schema' ),
)
);

register_rest_route(
'jetpack/v4',
'/publicize/(?P<postId>\d+)',
Expand Down Expand Up @@ -330,34 +315,6 @@ public function get_jetpack_social_connections_update_schema() {
return rest_default_additional_properties_to_false( $schema );
}

/**
* Retrieves the JSON schema for dismissing notices.
*
* @return array Schema data.
*/
public function get_dismiss_notice_endpoint_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'jetpack-social-dismiss-notice',
'type' => 'object',
'properties' => array(
'notice' => array(
'description' => __( 'Name of the notice to dismiss', 'jetpack-publicize-pkg' ),
'type' => 'string',
'enum' => array( 'instagram', 'advanced-upgrade-nudge-admin', 'advanced-upgrade-nudge-editor' ),
'required' => true,
),
'reappearance_time' => array(
'description' => __( 'Time when the notice should reappear', 'jetpack-publicize-pkg' ),
'type' => 'integer',
'default' => 0,
),
),
);

return rest_default_additional_properties_to_false( $schema );
}

/**
* Gets the current Publicize connections, with the resolt of testing them, for the site.
*
Expand Down Expand Up @@ -423,31 +380,6 @@ public static function get_social_product_info() {
);
}

/**
* Dismisses a notice to prevent it from appearing again.
*
* @param WP_REST_Request $request The request object, which includes the parameters.
* @return WP_REST_Response|WP_Error True if the request was successful, or a WP_Error otherwise.
*/
public function update_dismissed_notices( $request ) {
$notice = $request->get_param( 'notice' );
$reappearance_time = $request->get_param( 'reappearance_time' );
$dismissed_notices = get_option( Publicize::OPTION_JETPACK_SOCIAL_DISMISSED_NOTICES );

if ( ! is_array( $dismissed_notices ) ) {
$dismissed_notices = array();
}

if ( array_key_exists( $notice, $dismissed_notices ) && $dismissed_notices[ $notice ] === $reappearance_time ) {
return rest_ensure_response( array( 'success' => true ) );
}

$dismissed_notices[ $notice ] = $reappearance_time;
update_option( Publicize::OPTION_JETPACK_SOCIAL_DISMISSED_NOTICES, $dismissed_notices );

return rest_ensure_response( array( 'success' => true ) );
}

/**
* Calls the WPCOM endpoint to reshare the post.
*
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
),
'jetpack-publicize-pkg' => array(
'path' => 'jetpack_vendor/automattic/jetpack-publicize',
'ver' => '0.60.2-alpha1740396408',
'ver' => '0.61.0-alpha1740401280',
),
'jetpack-sync' => array(
'path' => 'jetpack_vendor/automattic/jetpack-sync',
Expand Down
Loading

0 comments on commit 7f89780

Please sign in to comment.