aboutsummaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/command.c b/command.c
index 1b70369..53d65f5 100644
--- a/command.c
+++ b/command.c
@@ -120,7 +120,7 @@ static bool cmd_create_room(struct conn_data *data,const char *tag,const char **
net_send_error(data->fd,tag,"Not logged in");
return false;
}
- userdata_mark_active(data->userid,data->fd);
+ userdata_mark_active(data->userid,data->fd,true);
struct db_name_id room=db_create_room();
db_add_member(room.id,data->userid);
bool closed=net_send_name(data->fd,tag,room.name);
@@ -133,7 +133,7 @@ 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;
}
- userdata_mark_active(data->userid,data->fd);
+ userdata_mark_active(data->userid,data->fd,true);
const char *roomname=args[0];
i64 roomid=db_find_room(roomname);
if(roomid==-1){
@@ -194,7 +194,7 @@ 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;
}
- userdata_mark_active(data->userid,data->fd);
+ userdata_mark_active(data->userid,data->fd,true);
const char *roomname=args[0];
const char *message=args[1];
i64 roomid=db_find_room(roomname);
@@ -318,6 +318,21 @@ static bool cmd_delete_firebase_token(struct conn_data *data,const char *tag,con
return net_send_ok(data->fd,tag);
}
+static bool cmd_user_active(struct conn_data *data,const char *tag,const char **args){
+ if(data->userid==-1){
+ net_send_error(data->fd,tag,"Not logged in");
+ return false;
+ }
+ char *endp;
+ i64 active=strtoll(args[0],&endp,10);
+ if(args[0][0]=='\0'||*endp!='\0'||active<0){
+ debug("Connection fd=%d sent an invalid number for 'user_active': '%s'",data->fd,args[0]);
+ return true;
+ }
+ userdata_mark_active(data->userid,data->fd,active>0);
+ return net_send_ok(data->fd,tag);
+}
+
struct cmd_info{
const char *cmdname;
@@ -340,6 +355,7 @@ static const struct cmd_info commands[]={
{"is_online",1,false,cmd_is_online},
{"firebase_token",1,false,cmd_firebase_token},
{"delete_firebase_token",1,false,cmd_delete_firebase_token},
+ {"user_active",1,false,cmd_user_active},
};
#define NCOMMANDS (sizeof(commands)/sizeof(commands[0]))