um_regonlymsg: copy auto-accept logic from +g

This commit is contained in:
Ed Kellett 2021-06-09 12:52:24 +01:00
parent d24434edb7
commit c5d7c5ed44

View file

@ -94,6 +94,35 @@ allow_message(struct Client *source_p, struct Client *target_p)
return false; 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 static void
h_hdl_invite(void *vdata) h_hdl_invite(void *vdata)
{ {
@ -105,6 +134,12 @@ h_hdl_invite(void *vdata)
if (data->approved) if (data->approved)
return; 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)) if (allow_message(source_p, target_p))
return; return;
@ -125,6 +160,12 @@ h_hdl_privmsg_user(void *vdata)
if (data->approved) if (data->approved)
return; 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)) if (allow_message(source_p, target_p))
return; return;