- rp = tr_rp_realm_iter_first(iter, ctable, comm_id);
- while(rp) {
- tr_debug("<<<<<<<<<<<<<<<<<<<<<<<<< GOT RP REALM ");
- memb = tr_comm_table_find_rp_memb(ctable,
- tr_rp_realm_get_id(rp),
- comm_id);
- json_array_append_new(jarray, tr_comm_memb_to_json(memb));
- rp = tr_rp_realm_iter_next(iter);
+ realm = NULL;
+
+ /* Do not display the full realm json here, only the name and info relevant to the community listing */
+ for (realm = tr_realm_iter_first(iter, ctable, comm_name);
+ realm != NULL;
+ realm = tr_realm_iter_next(iter)) {
+ if (realm->role == role) {
+ realm_json = json_object();
+ OBJECT_SET_OR_FAIL(realm_json, "realm",
+ tr_name_to_json_string(tr_realm_get_id(realm)));
+ memb = tr_comm_table_find_memb(ctable,
+ tr_realm_get_id(realm),
+ comm_name);
+ if (memb == NULL) {
+ /* This should not happen - there must be a matching membership if we
+ * believed the realm was in the community in the first place! */
+ goto cleanup;
+ }
+ OBJECT_SET_OR_FAIL(realm_json, "sources",
+ tr_comm_memb_sources_to_json(memb));
+ json_array_append_new(jarray, realm_json);
+ realm_json = NULL; /* so we don't free this twice during cleanup */
+ }