-/* cmd_neonserv_invite.c - NeonServ v5.3
+/* cmd_neonserv_invite.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
CMD_BIND(neonserv_cmd_invite) {
if(neonserv_cmd_invite_is_timeout(argv[0], chan->name)) {
- reply(getTextBot(), user, "NS_INVITE_TIMEOUT", argv[0], chan->name);
+ reply(textclient, user, "NS_INVITE_TIMEOUT", argv[0], chan->name);
return;
}
struct UserNode *cuser = getUserByNick(argv[0]);
if(!cuser) {
cuser = createTempUser(argv[0]);
if(!cuser) {
- reply(getTextBot(), user, "NS_USER_UNKNOWN", argv[0]);
+ reply(textclient, user, "NS_USER_UNKNOWN", argv[0]);
return;
}
cuser->flags |= USERFLAG_ISTMPUSER;
} else if(getChanUser(cuser, chan)) {
- reply(getTextBot(), user, "NS_INVITE_ON_CHAN", cuser->nick, chan->name);
+ reply(textclient, user, "NS_INVITE_ON_CHAN", cuser->nick, chan->name);
/* BUG
This check does not work if the user is invisible (CHMODE +D/+d)
to fix this we'd need to request the full userlist...
return;
}
if(cuser->flags & USERFLAG_ISAUTHED) {
- neonserv_cmd_invite_async1(client, getTextBot(), user, chan, event, argv[0], cuser->auth);
+ neonserv_cmd_invite_async1(client, textclient, user, chan, event, argv[0], cuser->auth);
} else {
struct neonserv_cmd_invite_cache *cache = malloc(sizeof(*cache));
if (!cache) {
- perror("malloc() failed");
+ printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
return;
}
cache->client = client;
- cache->textclient = getTextBot();
+ cache->textclient = textclient;
cache->user = user;
cache->chan = chan;
cache->event = event;
}
static void neonserv_cmd_invite_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth) {
- if(auth) {
+ if(auth && (!(user->flags & USERFLAG_ISAUTHED) || stricmp(auth, user->auth))) {
MYSQL_RES *res;
MYSQL_ROW row;
- printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
+ printf_mysql_query("SELECT `user_id`, `user_block_invites` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
res = mysql_use();
if ((row = mysql_fetch_row(res)) != NULL) {
+ //check if the user has blocked invites globally
+ if(!strcmp(row[1], "1")) {
+ reply(textclient, user, "NS_INVITE_GLOBALLY_BLOCKED", nick);
+ return;
+ }
//check if the user has set noinvite
printf_mysql_query("SELECT `id` FROM `noinvite` WHERE `uid` = '%s' AND `cid` = '%d'", row[0], chan->channel_id);
res = mysql_use();
static struct neonserv_cmd_invite_timeout* neonserv_cmd_invite_add_timeout(char *nick, char *chan) {
struct neonserv_cmd_invite_timeout *entry = malloc(sizeof(*entry));
if (!entry) {
- perror("malloc() failed");
+ printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
return NULL;
}
entry->next = NULL;