aboutsummaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/command.c b/command.c
index 0ae7fa3..c5891d5 100644
--- a/command.c
+++ b/command.c
@@ -9,6 +9,7 @@
#include "db.h"
#include "event.h"
#include "net.h"
+#include "firebase.h"
#include "user_data.h"
#include "util.h"
@@ -213,6 +214,7 @@ static bool cmd_send(struct conn_data *data,const char *tag,const char **args){
roomname,username,timestamp,message);
event_emit_message(timestamp,message,username,roomname);
+ firebase_send_message(roomname,roomid,username,message);
free(username);
struct db_user_list members=db_list_members(roomid);
@@ -295,6 +297,15 @@ static bool cmd_is_online(struct conn_data *data,const char *tag,const char **ar
return net_send_number(data->fd,tag,nfds);
}
+static bool cmd_firebase_token(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;
+ }
+ db_add_token(data->userid,args[0]);
+ return net_send_ok(data->fd,tag);
+}
+
struct cmd_info{
const char *cmdname;
@@ -315,6 +326,7 @@ static const struct cmd_info commands[]={
{"history",2,false,cmd_history},
{"ping",0,false,cmd_ping},
{"is_online",1,false,cmd_is_online},
+ {"firebase_token",1,false,cmd_firebase_token},
};
#define NCOMMANDS (sizeof(commands)/sizeof(commands[0]))