From c5d7c5ed44049f2b5799b72b89ec82a6aa6317e4 Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Wed, 9 Jun 2021 12:52:24 +0100 Subject: [PATCH] um_regonlymsg: copy auto-accept logic from +g --- modules/um_regonlymsg.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/um_regonlymsg.c b/modules/um_regonlymsg.c index 79f8ab0f..aaafe800 100644 --- a/modules/um_regonlymsg.c +++ b/modules/um_regonlymsg.c @@ -94,6 +94,35 @@ allow_message(struct Client *source_p, struct Client *target_p) return false; } +static bool +add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_p, struct Client *target_p) +{ + if (!MyClient(source_p)) + return true; + + if(msgtype != MESSAGE_TYPE_NOTICE && + IsSetRegOnlyMsg(source_p) && + !accept_message(target_p, source_p) && + !IsOperGeneral(target_p)) + { + if(rb_dlink_list_length(&source_p->localClient->allow_list) < + (unsigned long)ConfigFileEntry.max_accept) + { + rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list); + rb_dlinkAddAlloc(source_p, &target_p->on_allow_list); + } + else + { + sendto_one_numeric(source_p, ERR_OWNMODE, + form_str(ERR_OWNMODE), + target_p->name, "+R"); + return false; + } + } + + return true; +} + static void h_hdl_invite(void *vdata) { @@ -105,6 +134,12 @@ h_hdl_invite(void *vdata) if (data->approved) return; + if (!add_callerid_accept_for_source(MESSAGE_TYPE_PRIVMSG, source_p, target_p)) + { + data->approved = ERR_NONONREG; + return; + } + if (allow_message(source_p, target_p)) return; @@ -125,6 +160,12 @@ h_hdl_privmsg_user(void *vdata) if (data->approved) return; + if (!add_callerid_accept_for_source(data->msgtype, source_p, target_p)) + { + data->approved = ERR_NONONREG; + return; + } + if (allow_message(source_p, target_p)) return;