diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-08 11:47:29 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-08 11:47:29 +0200 |
commit | e9f1a60fcc4e0d6ccc10b0961c0256fa0a729568 (patch) | |
tree | 5a32de0ee406430fcb95b3fd095a527aa6b0fce7 | |
parent | 2b86c851562f86f69acbf4b773107077680d5068 (diff) |
Send _push join/invite
-rw-r--r-- | command.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -209,6 +209,33 @@ static bool cmd_invite(struct conn_data *data,const char *tag,const char **args) } db_add_member(roomid,user2); + + const char *username=args[1]; + char *joinbuf=NULL; + i64 joinbuflen=asprintf(&joinbuf,"_push join %s %s\n",args[0],username); + char *invitebuf=NULL; + i64 invitebuflen=asprintf(&invitebuf,"_push invite %s\n",args[0]); + + struct db_user_list members=db_list_members(roomid); + for(i64 i=0;i<members.count;i++){ + i64 nfds; + const int *fds=userdata_online(members.list[i].id,&nfds); + if(nfds<=0)continue; + for(i64 j=0;j<nfds;j++){ + if(fds[j]!=data->fd){ + if(members.list[i].id==user2){ + send_raw_text(fds[j],invitebuf,invitebuflen); + } else { + send_raw_text(fds[j],joinbuf,joinbuflen); + } + } + } + } + + db_nullify_user_list(members); + free(joinbuf); + free(invitebuf); + return send_ok(data->fd,tag); } |