Commit 0a926198 authored by Tiago Cunha's avatar Tiago Cunha Committed by GitHub

Merge branch 'develop' into fix/attachment-ui

parents 044a9d5b ec29bb97
...@@ -3,6 +3,9 @@ package chat.rocket.android.service.ddp.base; ...@@ -3,6 +3,9 @@ package chat.rocket.android.service.ddp.base;
import android.content.Context; import android.content.Context;
import io.realm.RealmObject; import io.realm.RealmObject;
import org.json.JSONException;
import org.json.JSONObject;
import chat.rocket.android.api.DDPClientWrapper; import chat.rocket.android.api.DDPClientWrapper;
import chat.rocket.android.model.ddp.User; import chat.rocket.android.model.ddp.User;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
...@@ -30,4 +33,24 @@ public class ActiveUsersSubscriber extends AbstractBaseSubscriber { ...@@ -30,4 +33,24 @@ public class ActiveUsersSubscriber extends AbstractBaseSubscriber {
protected Class<? extends RealmObject> getModelClass() { protected Class<? extends RealmObject> getModelClass() {
return User.class; return User.class;
} }
@Override
protected JSONObject customizeFieldJson(JSONObject json) throws JSONException {
json = super.customizeFieldJson(json);
// The user object may have some children without a proper primary key (ex.: settings)
// Here we identify this and add a local key
// Only happens here when the logged user receives its own data
if (json.has("settings")) {
final JSONObject settingsJson = json.getJSONObject("settings");
settingsJson.put("id", json.getString("_id"));
if (settingsJson.has("preferences")) {
final JSONObject preferencesJson = settingsJson.getJSONObject("preferences");
preferencesJson.put("id", json.getString("_id"));
}
}
return json;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment