aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--matrix-connection.c12
-rw-r--r--matrix-sync.c5
2 files changed, 13 insertions, 4 deletions
diff --git a/matrix-connection.c b/matrix-connection.c
index 925fef6..b77942a 100644
--- a/matrix-connection.c
+++ b/matrix-connection.c
@@ -109,6 +109,14 @@ static void _sync_complete(MatrixConnectionData *ma, gpointer user_data,
PurpleConnection *pc = ma->pc;
const gchar *next_batch;
+ ma->active_sync = NULL;
+
+ if(body == NULL) {
+ purple_connection_error_reason(pc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
+ "Couldn't parse sync response");
+ return;
+ }
+
purple_connection_update_progress(pc, _("Connected"), 2, 3);
purple_connection_set_state(pc, PURPLE_CONNECTED);
@@ -116,8 +124,8 @@ static void _sync_complete(MatrixConnectionData *ma, gpointer user_data,
/* Start the next sync */
if(next_batch == NULL) {
- purple_connection_error_reason(pc,
- PURPLE_CONNECTION_ERROR_OTHER_ERROR, "No next_batch field");
+ purple_connection_error_reason(pc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
+ "No next_batch field");
return;
}
purple_account_set_string(pc->account, PRPL_ACCOUNT_OPT_NEXT_BATCH,
diff --git a/matrix-sync.c b/matrix-sync.c
index 2f3b887..9190656 100644
--- a/matrix-sync.c
+++ b/matrix-sync.c
@@ -177,6 +177,8 @@ void matrix_sync_parse(PurpleConnection *pc, JsonNode *body,
rooms = matrix_json_object_get_object_member(rootObj, "rooms");
joined_rooms = matrix_json_object_get_object_member(rooms, "joined");
+ *next_batch = matrix_json_object_get_string_member(rootObj, "next_batch");
+
if(joined_rooms == NULL) {
purple_debug_warning("matrixprpl", "didn't find joined rooms list\n");
return;
@@ -187,10 +189,9 @@ void matrix_sync_parse(PurpleConnection *pc, JsonNode *body,
const gchar *room_id = elem->data;
JsonObject *room_data = matrix_json_object_get_object_member(
joined_rooms, room_id);
+ purple_debug_info("matrixprpl", "Syncing room %s", room_id);
matrix_sync_room(room_id, room_data, pc);
}
g_list_free(room_ids);
-
- *next_batch = matrix_json_object_get_string_member(rootObj, "next_batch");
}