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

Commit 3258ec3

Browse files
committed
Exclude unactive Jetpack sites
1 parent 7dc4ed3 commit 3258ec3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/WordPressKit/Models/RemoteBlog.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ import Foundation
3737
/// Features available for the current blog's plan.
3838
public var planActiveFeatures = [String]()
3939

40-
/// Indicates whether it's a jetpack site, or not.
40+
/// Indicates whether the jetpack connection is active.
4141
public var jetpack: Bool = false
4242

43+
/// Indicates whether it's a Jetpack connected site.
44+
public var jetpackConnection: Bool = false
45+
4346
/// Boolean indicating whether the current user has Admin privileges, or not.
4447
public var isAdmin: Bool = false
4548

@@ -70,6 +73,7 @@ import Foundation
7073
self.url = json.string(forKey: "URL") ?? ""
7174
self.xmlrpc = json.string(forKeyPath: "meta.links.xmlrpc")
7275
self.jetpack = json.number(forKey: "jetpack")?.boolValue ?? false
76+
self.jetpackConnection = json.number(forKey: "jetpack_connection")?.boolValue ?? false
7377
self.icon = json.string(forKeyPath: "icon.img")
7478
self.capabilities = json.object(forKey: "capabilities") as? [String: Bool] ?? [:]
7579
self.isAdmin = json.number(forKeyPath: "capabilities.manage_options")?.boolValue ?? false

Sources/WordPressKit/Services/AccountServiceRemoteREST.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,16 @@ - (NSArray *)remoteBlogsFromJSONArray:(NSArray *)jsonBlogs
391391
// Exclude deleted sites from query result, since the app does not handle deleted sites properly.
392392
// I tried to use query arguments `site_visibility=visible` and `site_activity=active`, but neither excludes
393393
// deleted sites.
394-
return !blog.isDeleted;
394+
if (blog.isDeleted) {
395+
return false;
396+
}
397+
398+
// Exclude sites that are connected via Jetpack, but without an active Jetpack connection.
399+
if (blog.jetpackConnection && !blog.jetpack) {
400+
return false;
401+
}
402+
403+
return true;
395404
}];
396405
}
397406

0 commit comments

Comments
 (0)