aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firebase.c2
-rw-r--r--user_data.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/firebase.c b/firebase.c
index d11545f..1f4fb26 100644
--- a/firebase.c
+++ b/firebase.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include "db.h"
#include "firebase.h"
+#include "user_data.h"
#define JS_PLUGIN_PATH "firebase-io/firebase-io.js"
@@ -126,6 +127,7 @@ void firebase_send_message(const char *room,i64 roomid,const char *user,const ch
struct db_user_list members=db_list_members(roomid);
for(i64 i=0;i<members.count;i++){
+ if(userdata_online(members.list[i].id,NULL))continue;
struct db_strings_list tokens=db_user_tokens(members.list[i].id);
for(i64 j=0;j<tokens.count;j++){
token_send(tokens.list[j],room,user,msg);
diff --git a/user_data.c b/user_data.c
index 5e7c028..e7d2e2a 100644
--- a/user_data.c
+++ b/user_data.c
@@ -90,10 +90,10 @@ void userdata_unregister(i64 userid,int fd){
const int* userdata_online(i64 userid,i64 *nfds){
struct hash_item *item=find_userdata(userid);
if(!item){
- *nfds=0;
+ if(nfds)*nfds=0;
return NULL;
}
assert(item->data.fds_len!=0);
- *nfds=item->data.fds_len;
+ if(nfds)*nfds=item->data.fds_len;
return item->data.fds;
}