Compare commits

..

No commits in common. "8612aae24c06ebecdae1c855df7e327de5b80091" and "276b7fecd7d28ed370368daca7c52d58e043d70e" have entirely different histories.

5 changed files with 23 additions and 17 deletions

View file

@ -29,7 +29,7 @@
}, },
"States": { "States": {
"fields": { "fields": {
"events": { "type": "array" } "events": { "type": "[StrippedStateEvent]" }
}, },
"type": "struct" "type": "struct"
}, },

View file

@ -51,7 +51,7 @@ ROUTE_IMPL(RouteCapabilities, path, argp)
/* TODO: When more room versions are implemented, add them to /* TODO: When more room versions are implemented, add them to
* roomVersions */ * roomVersions */
HashMapSet(roomVersions, "1", JsonValueString("stable")); HashMapSet(roomVersions, "1", JsonValueString("unstable"));
JsonSet(capabilities, JsonValueString("1"), 2, "m.room_versions", "default"); JsonSet(capabilities, JsonValueString("1"), 2, "m.room_versions", "default");
JsonSet(capabilities, JsonValueObject(roomVersions), 2, "m.room_versions", "available"); JsonSet(capabilities, JsonValueObject(roomVersions), 2, "m.room_versions", "available");

View file

@ -60,8 +60,6 @@ ROUTE_IMPL(RouteMessages, path, argp)
int limit = strtol(limitStr, NULL, 10); int limit = strtol(limitStr, NULL, 10);
Array *messages = NULL; Array *messages = NULL;
Array *state = NULL;
size_t i;
Room *room = NULL; Room *room = NULL;
@ -138,18 +136,7 @@ ROUTE_IMPL(RouteMessages, path, argp)
Free(startId); Free(startId);
} }
response = HashMapCreate(); response = HashMapCreate();
state = ArrayCreate();
JsonSet(response, JsonValueArray(messages), 1, "chunk"); JsonSet(response, JsonValueArray(messages), 1, "chunk");
for (i = 0; i < ArraySize(messages); i++)
{
HashMap *e = JsonValueAsObject(ArrayGet(messages, i));
if (HashMapGet(e, "state_key"))
{
ArrayAdd(state, JsonValueDuplicate(ArrayGet(messages, i)));
}
}
JsonSet(response, JsonValueArray(state), 1, "state");
JsonSet(response, JsonValueString(from), 1, "start");
if (end) if (end)
{ {
JsonSet(response, JsonValueString(end), 1, "end"); JsonSet(response, JsonValueString(end), 1, "end");

View file

@ -50,6 +50,15 @@ ClientfyEventSync(HashMap *pdu)
return ret; return ret;
} }
static StrippedStateEvent
StripStateEventSync(HashMap *pdu)
{
StrippedStateEvent ret = { 0 };
char *ignored;
StrippedStateEventFromJson(pdu, &ret, &ignored);
return ret;
}
ROUTE_IMPL(RouteSync, path, argp) ROUTE_IMPL(RouteSync, path, argp)
{ {
@ -236,8 +245,13 @@ ROUTE_IMPL(RouteSync, path, argp)
while (StateIterate(state, &type, &key, (void **) &id)) while (StateIterate(state, &type, &key, (void **) &id))
{ {
HashMap *e = RoomEventFetch(r, id, true); HashMap *e = RoomEventFetch(r, id, true);
StrippedStateEvent rs = StripStateEventSync(e);
StrippedStateEvent *s = Malloc(sizeof(*s));
memcpy(s, &rs, sizeof(*s));
ArrayAdd(joined->state.events, JsonValueObject(e)); JsonFree(e);
ArrayAdd(joined->state.events, s);
Free(type); Free(type);
Free(key); Free(key);
} }

View file

@ -1318,11 +1318,13 @@ UserPushAccountData(User *user, char *key)
JsonValueFree(HashMapSet(join, JsonValueFree(HashMapSet(join,
key, JsonValueObject(accountEntry) key, JsonValueObject(accountEntry)
)); ));
Log(LOG_INFO, "user=%s's batch=%s", user->name, entry);
} }
DbUnlock(user->db, syncRef); DbUnlock(user->db, syncRef);
} }
DbListFree(entries); DbListFree(entries);
Log(LOG_INFO, "You have notified the '%s' about key=%s", user->name, key);
UserNotifyUser(user->name); UserNotifyUser(user->name);
} }
void void
@ -1459,6 +1461,8 @@ UserFillSyncDiff(User *user, char *batch)
return; return;
} }
Log(LOG_WARNING, "This is an initial sync.");
joins = UserListJoins(user); joins = UserListJoins(user);
syncRef = DbLock( syncRef = DbLock(
user->db, 4, "users", user->name, "sync", batch user->db, 4, "users", user->name, "sync", batch
@ -1740,7 +1744,8 @@ UserFetchMessages(User *user, int n, char *token, char **next)
bool toFree = true; bool toFree = true;
/* Push event into our message list, and check if we can use it */ /* Push event into our message list.
* TODO: Check if the user has the right to see the event/room. */
if (RoomIsEventVisible(room, user, curr)) if (RoomIsEventVisible(room, user, curr))
{ {
ArrayAdd(messages, event); ArrayAdd(messages, event);