aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/command.c b/command.c
index 97f4fce..6edf4ea 100644
--- a/command.c
+++ b/command.c
@@ -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);
}