[Store] Handle presences in store

This commit is contained in:
Christian Pauly 2019-08-07 08:50:05 +02:00
parent 8b8232d2ba
commit 83d747f5f5
1 changed files with 11 additions and 4 deletions

View File

@ -203,10 +203,17 @@ class Store {
/// Stores an UserUpdate object in the database. Must be called inside of
/// [transaction].
Future<void> storeUserEventUpdate(UserUpdate userUpdate) {
txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [
userUpdate.eventType,
json.encode(userUpdate.content["content"]),
]);
if (userUpdate.type == "account_data")
txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [
userUpdate.eventType,
json.encode(userUpdate.content["content"]),
]);
else if (userUpdate.type == "presence")
txn.rawInsert("INSERT OR REPLACE INTO Presence VALUES(?, ?)", [
userUpdate.eventType,
userUpdate.content["sender"],
json.encode(userUpdate.content["content"]),
]);
return null;
}