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

Commit 8010d09

Browse files
authored
Merge pull request #1403 from wordpress-mobile/issue/1402-cache-jetpack-user-email
Woo: Issue/1402 cache jetpack user email to SiteModel
2 parents 72684a4 + 0023aab commit 8010d09

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/model/SiteModel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class SiteModel extends Payload<BaseNetworkError> implements Identifiable
7070
// mIsJetpackConnected is true if Jetpack is installed, activated and connected to a WordPress.com account.
7171
@Column private boolean mIsJetpackConnected;
7272
@Column private String mJetpackVersion;
73+
@Column private String mJetpackUserEmail;
7374
@Column private boolean mIsAutomatedTransfer;
7475
@Column private boolean mIsWpComStore;
7576
@Column private boolean mHasWooCommerce;
@@ -555,6 +556,14 @@ public void setJetpackVersion(String jetpackVersion) {
555556
mJetpackVersion = jetpackVersion;
556557
}
557558

559+
public String getJetpackUserEmail() {
560+
return mJetpackUserEmail;
561+
}
562+
563+
public void setJetpackUserEmail(String jetpackUserEmail) {
564+
mJetpackUserEmail = jetpackUserEmail;
565+
}
566+
558567
public boolean isAutomatedTransfer() {
559568
return mIsAutomatedTransfer;
560569
}

fluxc/src/main/java/org/wordpress/android/fluxc/network/xmlrpc/site/SiteXMLRPCClient.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void fetchSite(final SiteModel site) {
104104
params.add(site.getPassword());
105105
params.add(new String[] {
106106
"software_version", "post_thumbnail", "default_comment_status", "jetpack_client_id",
107-
"blog_public", "home_url", "admin_url", "login_url", "blog_title", "time_zone" });
107+
"blog_public", "home_url", "admin_url", "login_url", "blog_title", "time_zone", "jetpack_user_email" });
108108
final XMLRPCRequest request = new XMLRPCRequest(
109109
site.getXmlRpcUrl(), XMLRPC.GET_OPTIONS, params,
110110
new Listener<Object>() {
@@ -261,6 +261,13 @@ private void setJetpackStatus(Map<?, ?> siteOptions, SiteModel oldModel) {
261261
} else {
262262
oldModel.setSiteId(0);
263263
}
264+
265+
// * Jetpack not installed: field "jetpack_user_email" not included in the response
266+
// * Jetpack installed but not activated: field "jetpack_user_email" not included in the response
267+
// * Jetpack installed, activated but not connected: field "jetpack_user_email" not included in the response
268+
// * Jetpack installed, activated and connected: field "jetpack_user_email" included and is correctly
269+
// set to the email of the jetpack connected user
270+
oldModel.setJetpackUserEmail(XMLRPCUtils.safeGetNestedMapValue(siteOptions, "jetpack_user_email", ""));
264271
}
265272

266273
private SiteModel updateSiteFromOptions(Object response, SiteModel oldModel) {

fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open class WellSqlConfig : DefaultWellConfig {
2727
annotation class AddOn
2828

2929
override fun getDbVersion(): Int {
30-
return 89
30+
return 90
3131
}
3232

3333
override fun getDbName(): String {
@@ -1003,6 +1003,9 @@ open class WellSqlConfig : DefaultWellConfig {
10031003
88 -> migrateAddOn(ADDON_WOOCOMMERCE, version) {
10041004
db.execSQL("ALTER TABLE WCOrderNoteModel ADD AUTHOR TEXT")
10051005
}
1006+
89 -> migrate(version) {
1007+
db.execSQL("ALTER TABLE SiteModel ADD JETPACK_USER_EMAIL TEXT")
1008+
}
10061009
}
10071010
}
10081011
db.setTransactionSuccessful()

0 commit comments

Comments
 (0)