Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Conversation

@crazytonyli
Copy link
Contributor

@crazytonyli crazytonyli commented Mar 31, 2025

Description

The app displays sites inaccessible Jetpack self-hosted sites(for example, deleted Jurassic Ninja sites). Similar to deleted WP.com sites, when switching to those sites, the app displays almost empty content. This PR removes those sites from API responses.

WordPressKit.zip

ℹ Please replace the above with a link to the issue this pull request addresses, as well as a summary of the implementation details.

Testing Details

ℹ Please replace this with a clear and concise description of the steps required to validate this pull request.


  • Please check here if your pull request includes additional test coverage.
  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages in Xcode.

Generated by 🚫 Danger

@crazytonyli crazytonyli force-pushed the filter-unaccessible-sites branch from d005bbe to aa4ea90 Compare March 31, 2025 10:09
@crazytonyli crazytonyli requested review from kean and pmusolino March 31, 2025 10:17
@crazytonyli crazytonyli marked this pull request as ready for review March 31, 2025 10:18
Copy link
Contributor

@pmusolino pmusolino left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm waiting for the final PR in the WordPress-iOS repo before approving it!

public var planActiveFeatures = [String]()

/// Indicates whether it's a jetpack site, or not.
/// Indicates whether the jetpack connection is active.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this comment apply to the jetpackConnection property?

/// Indicates whether the jetpack connection is active.
public var jetpack: Bool = false

Let's follow the Swift naming conversion and name these something like:

var isJetpackConnectionActive: Bool { get }
var isJetpackConnected: Bool { get } 
Indicates whether it's a Jetpack connected site.

Does this mean that the site is a non-WP.com site?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the API doc to match the properties on the HTTP API 777c651.

Does this mean that the site is a non-WP.com site?

I believe it's possible that atomic sites have jetpack_connection == true & jetpack == false. Just by jetpack_connection property alone, we can't tell if a site is a WP.com site.

}

// Exclude sites that are connected via Jetpack, but without an active Jetpack connection.
if (blog.jetpackConnection && !blog.jetpack) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does WP.com do in the same scenario? Does it also remove the site from your account? What does "active Jetpack" mean? Can a site temporarily become inactive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jetpack_connection = true means the site was connected to WP.com via jetpack.

jetpack = true means WP.com can still communicate with the site via Jetpack (a.k.a, jetpack connection is active).

You typically get jetpack_connection = true && jetpack = false when the site was connected to WP.com a while ago, but its domain expired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WP.com does not show sites with jetpack_connection = true && jetpack = false, hence the fix.

There is more complicated logic on WP.com (see here) to decide whether to show a site or not. I didn't try to understand all of them. But this PR fixes the particular case where the site domain has expired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can a site temporarily become inactive?

I think that's entirely possible, like when the site is down, or for whatever reason that WP.com decides that it can't communicate with the site.

Copy link
Contributor

@kean kean Apr 7, 2025

Choose a reason for hiding this comment

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

I'm not entirely sure how the logic on WP.com translate to this:

if ( hasJetpackActivePlugins( site ) && ! isJetpackSiteOrJetpackCloud( site ) ) { return false; }

Is there a good way to test it?

jetpack = true means WP.com can still communicate with the site via Jetpack (a.k.a, jetpack connection is active).

There is also a chance the UX on WP.com isn't optimal. WP.com can't not if the site was actually deleted or if it's a temporarily issue, can it? As a user, I'd probably expect it to show some kind of a message like "site is not responding" with a way to remove it from my WP.com account.

I'd also suggest moving filtering (the entire logic inside wpkit_filter) to the app. It's not WordPressKit job to decide what app displays.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't follow the exact filtering logic on calypso. This is the code I referenced when looking into the API responses.

// Sites connected through A4A plugin are listed on wordpress.com/sites even when Jetpack is deactivated.
export const isDisconnectedJetpackAndNotAtomic = ( site: SiteExcerptNetworkData ) => {
	return ! site?.is_wpcom_atomic && site?.jetpack_connection && ! site?.jetpack;
};

I'd also suggest moving filtering (the entire logic inside wpkit_filter) to the app. It's not WordPressKit job to decide what app displays.

Agreed. I'll do that.

@crazytonyli crazytonyli requested a review from kean April 6, 2025 23:32
Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

Please make sure to rebase and re-create the binary if needed.

@crazytonyli crazytonyli merged commit ed050d0 into wpios-edition Apr 9, 2025
2 of 4 checks passed
@crazytonyli crazytonyli deleted the filter-unaccessible-sites branch April 9, 2025 00:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants