Skip to content

Commit 04e7fe0

Browse files
Fix CMM-940: Allow accessing Jetpack sites without the jetpack plugin (#24976)
* Fix CMM-940: Allow accessing Jetpack sites without the jetpack plugin * Update release notes * Add a missing release note * Fix a typo Co-authored-by: Jeremy Massel <[email protected]> * Fix an issue where jetpack site is not merged after WP.com log in * Update HTTP stubs --------- Co-authored-by: Jeremy Massel <[email protected]>
1 parent e53643b commit 04e7fe0

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

Modules/Sources/WordPressKitObjC/AccountServiceRemoteREST.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,19 @@ - (void)getBlogsWithParameters:(NSDictionary *)parameters
376376
{
377377
NSString *requestUrl = [self pathForEndpoint:@"me/sites"
378378
withVersion:WordPressComRESTAPIVersion_1_2];
379+
// site_activity=active filters out many sites that are not longer available.
380+
//
381+
// For example, if you have a self-hosted site that's connected to a WP.com account, and later the site domain expires
382+
// and couldn't be accessed, we don't want to show this site in the app. These sites are filtered out by the
383+
// `site_activity=active` parameter.
384+
//
385+
// For reference, this paramter is hard-coded in "My Sites" in calypso:
386+
// https://github.com/Automattic/wp-calypso/blob/64806d21520e5489b30fbabf04e2f427a3ad392c/packages/api-core/src/me-sites/fetchers.ts#L30
387+
if (parameters[@"site_activity"] == nil) {
388+
NSMutableDictionary *updated = [NSMutableDictionary dictionaryWithDictionary:parameters];
389+
updated[@"site_activity"] = @"active";
390+
parameters = updated;
391+
}
379392
[self.wordPressComRESTAPI get:requestUrl
380393
parameters:parameters
381394
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
@@ -417,11 +430,6 @@ - (NSArray *)remoteBlogsFromJSONArray:(NSArray *)jsonBlogs
417430
return false;
418431
}
419432

420-
// Exclude sites that are connected via Jetpack, but without an active Jetpack connection.
421-
if (blog.jetpackConnection && !blog.jetpack) {
422-
return false;
423-
}
424-
425433
return true;
426434
}];
427435
}

RELEASE-NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* [*] Add permalink preview in the slug editor and make other improvements [#24949]
1515
* [*] Add "Taxonomies" to Site Settings [#24955]
1616
* [*] Update "Categories" picker to indicate multiple selection [#24952]
17+
* [*] Fix a bug where the app can't access some Jetpack connected sites [#24976]
18+
* [*] Add support for editing custom taxonomy terms from "Post Settings" [#24964]
1719

1820
26.4
1921
-----

Tests/KeystoneTests/Resources/Mocks/User/me-sites-with-jetpack.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"is_following": false,
1818
"is_private": false,
1919
"jetpack": false,
20+
"jetpack_connection": false,
2021
"lang": "en",
2122
"logo": {
2223
"id": 0,
@@ -102,6 +103,7 @@
102103
"is_following": false,
103104
"is_private": false,
104105
"jetpack": true,
106+
"jetpack_connection": true,
105107
"lang": "en",
106108
"logo": {
107109
"id": 0,

WordPress/Classes/Services/BlogService.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,12 @@ - (void)updateBlogWithRemoteBlog:(RemoteBlog *)remoteBlog account:(WPAccount *)a
493493
{
494494
Blog *blog = [self findBlogWithDotComID:remoteBlog.blogID inAccount:account];
495495

496-
if (!blog && remoteBlog.jetpack) {
496+
// Previously the `remoteBlog.jetpack` property was used to check if the `blog` is connected to Jetpack.
497+
// However, the `jetpack` property indicated whether the Jetpack plugin is installed, and we should check the
498+
// `jetpack_connection` property instead.
499+
// See this calypso code for reference:
500+
// https://github.com/Automattic/wp-calypso/blob/61a1eb0968da82e62d992f8d081a4ab3075c7719/client/dashboard/utils/site-types.ts#L3
501+
if (!blog && remoteBlog.jetpackConnection) {
497502
blog = [self migrateRemoteJetpackBlog:remoteBlog forAccount:account inContext:context];
498503
}
499504

0 commit comments

Comments
 (0)