added missing "user" attribute to "online-status" event.

E.g. ```{"event": "online-status", "online": true, "when": "2015-05-20 00:16:40", "state": 1, "user": {"username": ... }}```
This commit is contained in:
luckydonald 2015-05-20 00:33:10 +02:00
parent 548c2b18e0
commit 3963eca8ca
3 changed files with 8 additions and 3 deletions

View File

@ -2574,7 +2574,7 @@ void user_status_upd (struct tgl_state *TLS, struct tgl_user *U) {
mpop_color (ev);
} else {
#ifdef USE_JSON
json_t *res = json_pack_user_status(&U->status);
json_t *res = json_pack_user_status(U);
char *s = json_dumps (res, 0);
mprintf (ev, "%s\n", s);
json_decref (res);

View File

@ -389,8 +389,13 @@ int str_format_time(long when, char* string)
return sprintf (string, "%04d-%02d-%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
}
json_t *json_pack_user_status (struct tgl_user_status *S) {
json_t *json_pack_user_status (struct tgl_user *U) {
json_t *res = json_object ();
struct tgl_user_status *S = &U->status;
json_object ();
json_t *user_res = json_object ();
json_pack_user(user_res, (void *) U);
assert (json_object_set (res, "user", user_res) >= 0);
assert (json_object_set (res, "online", json_boolean (S->online == 1)) >= 0);
assert (json_object_set (res, "state", json_integer (S->online)) >= 0);
if (S->online > 0 || S->online == -1) {

View File

@ -9,6 +9,6 @@ json_t *json_pack_message (struct tgl_message *M);
json_t *json_pack_updates (unsigned flags);
json_t *json_pack_peer (tgl_peer_id_t id, tgl_peer_t *P);
json_t *json_pack_read (struct tgl_message *M);
json_t *json_pack_user_status (struct tgl_user_status *S);
json_t *json_pack_user_status (struct tgl_user *U);
#endif
#endif