forked from Telodendria/Telodendria
[MOD/WIP] Separate DB entries for the txns
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
This commit is contained in:
parent
dc0e463c27
commit
4918932a0e
1 changed files with 27 additions and 9 deletions
34
src/User.c
34
src/User.c
|
@ -977,39 +977,57 @@ HashMap *
|
|||
UserGetTransaction(User *user, char *transaction, char *path)
|
||||
{
|
||||
HashMap *devices;
|
||||
DbRef *ref;
|
||||
|
||||
if (!user || !transaction || !path)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
devices = JsonValueAsObject(
|
||||
HashMapGet(UserGetDevices(user), UserGetDeviceId(user))
|
||||
ref = DbLock(user->db,
|
||||
4,
|
||||
"users", user->name,
|
||||
"txns", UserGetDeviceId(user)
|
||||
);
|
||||
|
||||
return JsonDuplicate(JsonValueAsObject(
|
||||
JsonGet(devices, 3, "transactions", path, transaction)
|
||||
));
|
||||
devices = DbJson(ref);
|
||||
devices = JsonValueAsObject(JsonGet(devices, 2, path, transaction));
|
||||
devices = JsonDuplicate(devices);
|
||||
DbUnlock(user->db, ref);
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
void
|
||||
UserSetTransaction(User *user, char *transaction, char *path, HashMap *resp)
|
||||
{
|
||||
HashMap *devices;
|
||||
DbRef *ref;
|
||||
if (!user || !transaction || !path || !resp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
devices = JsonValueAsObject(
|
||||
HashMapGet(UserGetDevices(user), UserGetDeviceId(user))
|
||||
if (!(ref = DbLock(user->db,
|
||||
4,
|
||||
"users", user->name,
|
||||
"txns", UserGetDeviceId(user)
|
||||
)))
|
||||
{
|
||||
ref = DbCreate(user->db,
|
||||
4,
|
||||
"users", user->name,
|
||||
"txns", UserGetDeviceId(user)
|
||||
);
|
||||
}
|
||||
devices = DbJson(ref);
|
||||
|
||||
/* Overwrite the transaction */
|
||||
JsonValueFree(JsonSet(
|
||||
devices, JsonValueObject(JsonDuplicate(resp)),
|
||||
3, "transactions", path, transaction
|
||||
2, path, transaction
|
||||
));
|
||||
|
||||
DbUnlock(user->db, ref);
|
||||
}
|
||||
void
|
||||
UserAddInvite(User *user, char *roomId)
|
||||
|
|
Loading…
Reference in a new issue