aboutsummaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-04-07 23:58:01 +0200
committertomsmeding <tom.smeding@gmail.com>2017-04-07 23:58:01 +0200
commit4dcb97eec19bcb5365fb355a81e299545b97ef75 (patch)
tree4f21b885d8e600de56d4b284265a8eb891d616e3 /command.c
parent93a75abb1daaf2d4dfa59c348d6a08d8ca0c9659 (diff)
Make protocol more consistent
Diffstat (limited to 'command.c')
-rw-r--r--command.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/command.c b/command.c
index a691171..97f4fce 100644
--- a/command.c
+++ b/command.c
@@ -227,12 +227,14 @@ static bool cmd_send(struct conn_data *data,const char *tag,const char **args){
return false;
}
+ i64 timestamp=make_timestamp();
db_create_message(roomid,data->userid,make_timestamp(),args[1]);
bool closed=send_ok(data->fd,tag);
char *pushbuf=NULL;
char *username=db_get_username(data->userid);
- i64 pushbuflen=asprintf(&pushbuf,"_push message %s %s %s\n",args[0],username,args[1]);
+ i64 pushbuflen=asprintf(&pushbuf,"_push message %s %s %" PRIi64 " %s\n",
+ args[0],username,timestamp,args[1]);
assert(pushbuf);
free(username);
@@ -289,8 +291,8 @@ static bool cmd_history(struct conn_data *data,const char *tag,const char **args
for(i64 i=ml.count-1;i>=0;i--){
char *username=db_get_username(ml.list[i].userid);
- len=asprintf(&buf,"%s history_item %" PRIi64 " %s %" PRIi64 " %s\n",
- tag,ml.count-1-i,username,ml.list[i].timestamp,ml.list[i].message);
+ len=asprintf(&buf,"%s history_message %" PRIi64 " %s %s %" PRIi64 " %s\n",
+ tag,ml.count-1-i,args[0],username,ml.list[i].timestamp,ml.list[i].message);
assert(buf);
closed=send_raw_text(data->fd,buf,len);
free(buf);