From 70aa1c05a3e2bc257644e098500929da73d6b441 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sun, 18 Mar 2007 10:42:49 -0400 Subject: [PATCH] Get rid of srvx-broadcast announcements. (They do not scale.) src/global.h (MESSAGE_RECIPIENT_ANNOUNCE): Remove. src/global.c (KEY_ANNOUNCEMENTS_DEFAULT): Remove. (global_conf): Remove announcements_default field. (message_create): Do not recognize "announce[ment]" target. (messageType): Remove MESSAGE_RECIPIENT_ANNOUNCE condition. (message_send): Remove MESSAGE_RECIPIENT_ANNOUNCE condition. (cmd_notice): Do not recognize "announce[ment]" target. (global_conf_read): Do not look up announcements_default key. src/global.help (TARGET): Remove ANNOUNCEMENT target. src/nickserv.h (struct handle_info): Remove announcements field. src/nickserv.c (KEY_ANNOUNCEMENTS): Remove. ("NSMSG_INVALID_ANNOUNCE"): Remove. ("NSMSG_SET_ANNOUNCEMENTS"): Remove. (register_handle): Do not assign to hi->announcements. (set_list): Remove ANNOUNCEMENTS from the default list. (opt_announcements): Remove. (nickserv_saxdb_write): Remove announcements code. (nickserv_db_read_handle): Remove announcements code. (init_nickserv): Do not register opt_announcements function. nickserv.help (SET): Remove ANNOUNCEMENTS option. --- src/global.c | 27 --------------------------- src/global.h | 1 - src/global.help | 1 - src/nickserv.c | 41 +---------------------------------------- src/nickserv.h | 1 - src/nickserv.help | 4 ---- 6 files changed, 1 insertion(+), 74 deletions(-) diff --git a/src/global.c b/src/global.c index d1aea5d..c749414 100644 --- a/src/global.c +++ b/src/global.c @@ -32,7 +32,6 @@ /* Global options */ #define KEY_DB_BACKUP_FREQ "db_backup_freq" -#define KEY_ANNOUNCEMENTS_DEFAULT "announcements_default" #define KEY_NICK "nick" /* Message data */ @@ -93,7 +92,6 @@ static struct log_type *G_LOG; static struct { unsigned long db_backup_frequency; - unsigned int announcements_default : 1; } global_conf; #define global_notice(target, format...) send_message(target , global , ## format) @@ -210,8 +208,6 @@ message_create(struct userNode *user, unsigned int argc, char *argv[]) flags |= MESSAGE_RECIPIENT_STAFF; } else if(!irccasecmp(argv[i], "channels")) { flags |= MESSAGE_RECIPIENT_CHANNELS; - } else if(!irccasecmp(argv[i], "announcement") || !irccasecmp(argv[i], "announce")) { - flags |= MESSAGE_RECIPIENT_ANNOUNCE; } else { global_notice(user, "GMSG_INVALID_TARGET", argv[i]); return NULL; @@ -250,10 +246,6 @@ messageType(const struct globalMessage *message) { return "staff"; } - else if(message->flags & MESSAGE_RECIPIENT_ANNOUNCE) - { - return "announcement"; - } else if(message->flags & MESSAGE_RECIPIENT_OPERS) { return "opers"; @@ -305,7 +297,6 @@ message_send(struct globalMessage *message) { struct userNode *user; unsigned long n; - dict_iterator_t it; if(message->flags & MESSAGE_RECIPIENT_CHANNELS) { @@ -318,20 +309,6 @@ message_send(struct globalMessage *message) return; } - if(message->flags & MESSAGE_RECIPIENT_ANNOUNCE) - { - char announce; - - for (it = dict_first(clients); it; it = iter_next(it)) { - user = iter_data(it); - if (user->uplink == self) continue; - announce = user->handle_info ? user->handle_info->announcements : '?'; - if (announce == 'n') continue; - if ((announce == '?') && !global_conf.announcements_default) continue; - notice_target(user->nick, message); - } - } - if(message->flags & MESSAGE_RECIPIENT_OPERS) { for(n = 0; n < curr_opers.used; n++) @@ -392,8 +369,6 @@ static GLOBAL_FUNC(cmd_notice) target = MESSAGE_RECIPIENT_OPERS; } else if(!irccasecmp(argv[1], "staff") || !irccasecmp(argv[1], "privileged")) { target |= MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS; - } else if(!irccasecmp(argv[1], "announcement") || !irccasecmp(argv[1], "announce")) { - target |= MESSAGE_RECIPIENT_ANNOUNCE; } else if(!irccasecmp(argv[1], "channels")) { target = MESSAGE_RECIPIENT_CHANNELS; } else { @@ -614,8 +589,6 @@ global_conf_read(void) str = database_get_data(conf_node, KEY_DB_BACKUP_FREQ, RECDB_QSTRING); global_conf.db_backup_frequency = str ? ParseInterval(str) : 7200; - str = database_get_data(conf_node, KEY_ANNOUNCEMENTS_DEFAULT, RECDB_QSTRING); - global_conf.announcements_default = str ? enabled_string(str) : 1; str = database_get_data(conf_node, KEY_NICK, RECDB_QSTRING); if(global && str) diff --git a/src/global.h b/src/global.h index b4bf81b..ecd753a 100644 --- a/src/global.h +++ b/src/global.h @@ -25,7 +25,6 @@ #define MESSAGE_RECIPIENT_HELPERS 0x002 #define MESSAGE_RECIPIENT_OPERS 0x004 #define MESSAGE_RECIPIENT_CHANNELS 0x008 -#define MESSAGE_RECIPIENT_ANNOUNCE 0x040 #define MESSAGE_OPTION_SOURCELESS 0x010 #define MESSAGE_OPTION_IMMEDIATE 0x020 diff --git a/src/global.help b/src/global.help index 3887d41..4916fef 100644 --- a/src/global.help +++ b/src/global.help @@ -28,7 +28,6 @@ "TARGET" ("$bTARGET$b", "$bTarget$b is used as a sub-command in many commands. It's values are:", "$bUSERS$b: The message will be sent to all users on the network including opers and helpers, but not channels.", - "$bANNOUNCEMENT$b: The message will be sent to all users who are configured to receive community announcements.", "$bHELPERS$b: The message will be sent to helpers only.", "$bOPERS$b: The message will be sent to opers only.", "$bSTAFF$b: The message will be sent to helpers and opers.", diff --git a/src/nickserv.c b/src/nickserv.c index 683fd71..234b6bf 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -96,7 +96,6 @@ #define KEY_ALLOWAUTH "allowauth" #define KEY_EPITHET "epithet" #define KEY_TABLE_WIDTH "table_width" -#define KEY_ANNOUNCEMENTS "announcements" #define KEY_MAXLOGINS "maxlogins" #define KEY_FAKEHOST "fakehost" #define KEY_NOTES "notes" @@ -287,14 +286,12 @@ static const struct message_entry msgtab[] = { { "NSMSG_CLONE_AUTH", "Warning: %s (%s@%s) authed to your account." }, { "NSMSG_SETTING_LIST", "$b$N account settings:$b" }, { "NSMSG_INVALID_OPTION", "$b%s$b is an invalid account setting." }, - { "NSMSG_INVALID_ANNOUNCE", "$b%s$b is an invalid announcements value." }, { "NSMSG_SET_INFO", "$bINFO: $b%s" }, { "NSMSG_SET_WIDTH", "$bWIDTH: $b%d" }, { "NSMSG_SET_TABLEWIDTH", "$bTABLEWIDTH: $b%d" }, { "NSMSG_SET_COLOR", "$bCOLOR: $b%s" }, { "NSMSG_SET_PRIVMSG", "$bPRIVMSG: $b%s" }, { "NSMSG_SET_STYLE", "$bSTYLE: $b%s" }, - { "NSMSG_SET_ANNOUNCEMENTS", "$bANNOUNCEMENTS: $b%s" }, { "NSMSG_SET_PASSWORD", "$bPASSWORD: $b%s" }, { "NSMSG_SET_FLAGS", "$bFLAGS: $b%s" }, { "NSMSG_SET_EMAIL", "$bEMAIL: $b%s" }, @@ -429,7 +426,6 @@ register_handle(const char *handle, const char *passwd, UNUSED_ARG(unsigned long hi = calloc(1, sizeof(*hi)); hi->userlist_style = HI_DEFAULT_STYLE; - hi->announcements = '?'; hi->handle = strdup(handle); safestrncpy(hi->passwd, passwd, sizeof(hi->passwd)); hi->infoline = NULL; @@ -2151,7 +2147,7 @@ set_list(struct userNode *user, struct handle_info *hi, int override) unsigned int i; char *set_display[] = { "INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", "STYLE", - "EMAIL", "ANNOUNCEMENTS", "MAXLOGINS", "LANGUAGE" + "EMAIL", "MAXLOGINS", "LANGUAGE" }; send_message(user, nickserv, "NSMSG_SETTING_LIST"); @@ -2305,33 +2301,6 @@ static OPTION_FUNC(opt_style) return 1; } -static OPTION_FUNC(opt_announcements) -{ - const char *choice; - - if (argc > 1) { - if (enabled_string(argv[1])) - hi->announcements = 'y'; - else if (disabled_string(argv[1])) - hi->announcements = 'n'; - else if (!strcmp(argv[1], "?") || !irccasecmp(argv[1], "default")) - hi->announcements = '?'; - else { - send_message(user, nickserv, "NSMSG_INVALID_ANNOUNCE", argv[1]); - return 0; - } - } - - switch (hi->announcements) { - case 'y': choice = user_find_message(user, "MSG_ON"); break; - case 'n': choice = user_find_message(user, "MSG_OFF"); break; - case '?': choice = "default"; break; - default: choice = "unknown"; break; - } - send_message(user, nickserv, "NSMSG_SET_ANNOUNCEMENTS", choice); - return 1; -} - static OPTION_FUNC(opt_password) { if (!override) { @@ -2820,11 +2789,6 @@ nickserv_saxdb_write(struct saxdb_context *ctx) { assert(hi->id); #endif saxdb_start_record(ctx, iter_key(it), 0); - if (hi->announcements != '?') { - flags[0] = hi->announcements; - flags[1] = 0; - saxdb_write_string(ctx, KEY_ANNOUNCEMENTS, flags); - } if (hi->cookie) { struct handle_cookie *cookie = hi->cookie; char *type; @@ -3481,8 +3445,6 @@ nickserv_db_read_handle(const char *handle, dict_t obj) } str = database_get_data(obj, KEY_USERLIST_STYLE, RECDB_QSTRING); hi->userlist_style = str ? str[0] : HI_STYLE_ZOOT; - str = database_get_data(obj, KEY_ANNOUNCEMENTS, RECDB_QSTRING); - hi->announcements = str ? str[0] : '?'; str = database_get_data(obj, KEY_SCREEN_WIDTH, RECDB_QSTRING); hi->screen_width = str ? strtoul(str, NULL, 0) : 0; str = database_get_data(obj, KEY_TABLE_WIDTH, RECDB_QSTRING); @@ -4072,7 +4034,6 @@ init_nickserv(const char *nick) dict_insert(nickserv_opt_dict, "TITLE", opt_title); dict_insert(nickserv_opt_dict, "FAKEHOST", opt_fakehost); } - dict_insert(nickserv_opt_dict, "ANNOUNCEMENTS", opt_announcements); dict_insert(nickserv_opt_dict, "MAXLOGINS", opt_maxlogins); dict_insert(nickserv_opt_dict, "LANGUAGE", opt_language); dict_insert(nickserv_opt_dict, "KARMA", opt_karma); diff --git a/src/nickserv.h b/src/nickserv.h index d19f13a..9e6ba89 100644 --- a/src/nickserv.h +++ b/src/nickserv.h @@ -108,7 +108,6 @@ struct handle_info { unsigned short screen_width; unsigned short table_width; unsigned char userlist_style; - unsigned char announcements; unsigned char maxlogins; char passwd[MD5_CRYPT_LENGTH+1]; char last_quit_host[USERLEN+HOSTLEN+2]; diff --git a/src/nickserv.help b/src/nickserv.help index b4a1b7e..a2f59a4 100644 --- a/src/nickserv.help +++ b/src/nickserv.help @@ -360,7 +360,6 @@ "/services/nickserv/email_enabled && /services/nickserv/disable_nicks" ( "/msg $N SET [ [value]]", "Changes your account settings for srvx. Settings are:", - "$bANNOUNCEMENTS$b: Indicates whether you wish to receive community announcements via the $G service.", "$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.", "$bEMAIL$b: Sets (or changes) your email address.", "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).", @@ -376,7 +375,6 @@ "/services/nickserv/email_enabled && !/services/nickserv/disable_nicks" ( "/msg $N SET [ [value]]", "Changes your account settings for srvx. Settings are:", - "$bANNOUNCEMENTS$b: Indicates whether you wish to receive community announcements via the $G service.", "$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.", "$bEMAIL$b: Sets (or changes) your email address.", "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).", @@ -392,7 +390,6 @@ "!/services/nickserv/email_enabled && /services/nickserv/disable_nicks" ( "/msg $N SET [ [value]]", "Changes your account settings for srvx. Settings are:", - "$bANNOUNCEMENTS$b: Indicates whether you wish to receive community announcements via the $G service.", "$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.", "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).", "$bLANGUAGE$b: Your preferred language for private messages from the services.", @@ -407,7 +404,6 @@ "!/services/nickserv/email_enabled && !/services/nickserv/disable_nicks" ( "/msg $N SET [ [value]]", "Changes your account settings for srvx. Settings are:", - "$bANNOUNCEMENTS$b: Indicates whether you wish to receive community announcements via the $G service.", "$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.", "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).", "$bLANGUAGE$b: Your preferred language for private messages from the services.", -- 2.20.1