aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/command.c b/command.c
index bcfa2e8..2695c93 100644
--- a/command.c
+++ b/command.c
@@ -136,7 +136,8 @@ static bool cmd_invite(struct conn_data *data,const char *tag,const char **args)
net_send_error(data->fd,tag,"Not logged in");
return false;
}
- i64 roomid=db_find_room(args[0]);
+ const char *roomname=args[0];
+ i64 roomid=db_find_room(roomname);
if(roomid==-1){
net_send_error(data->fd,tag,"Room not found");
return false;
@@ -161,9 +162,9 @@ static bool cmd_invite(struct conn_data *data,const char *tag,const char **args)
const char *username=args[1];
char *joinbuf=NULL;
- i64 joinbuflen=asprintf(&joinbuf,"_push join %s %s\n",args[0],username);
+ i64 joinbuflen=asprintf(&joinbuf,"_push join %s %s\n",roomname,username);
char *invitebuf=NULL;
- i64 invitebuflen=asprintf(&invitebuf,"_push invite %s\n",args[0]);
+ i64 invitebuflen=asprintf(&invitebuf,"_push invite %s\n",roomname);
struct db_user_list members=db_list_members(roomid);
for(i64 i=0;i<members.count;i++){
@@ -193,7 +194,9 @@ static bool cmd_send(struct conn_data *data,const char *tag,const char **args){
net_send_error(data->fd,tag,"Not logged in");
return false;
}
- i64 roomid=db_find_room(args[0]);
+ const char *roomname=args[0];
+ const char *message=args[1];
+ i64 roomid=db_find_room(roomname);
if(roomid==-1){
net_send_error(data->fd,tag,"Room not found");
return false;
@@ -204,13 +207,13 @@ static bool cmd_send(struct conn_data *data,const char *tag,const char **args){
}
i64 timestamp=make_timestamp();
- db_create_message(roomid,data->userid,make_timestamp(),args[1]);
+ db_create_message(roomid,data->userid,make_timestamp(),message);
bool closed=net_send_ok(data->fd,tag);
char *pushbuf=NULL;
char *username=db_get_username(data->userid);
i64 pushbuflen=asprintf(&pushbuf,"_push message %s %s %" PRIi64 " %s\n",
- args[0],username,timestamp,args[1]);
+ roomname,username,timestamp,message);
free(username);
struct db_user_list members=db_list_members(roomid);