invite: rework the way can_invite hook is called

This commit is contained in:
Ariadne Conill 2020-06-26 19:55:12 +00:00
parent 4436a7ca73
commit 4371dcbd55

View file

@ -145,24 +145,27 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
return; return;
} }
if (MyClient(source_p)) hdata.chptr = chptr;
{ hdata.msptr = msptr;
hdata.chptr = chptr; hdata.client = source_p;
hdata.msptr = msptr; hdata.target = target_p;
hdata.client = source_p; hdata.approved = !(is_chanop(msptr) || (chptr->mode.mode & MODE_FREEINVITE));
hdata.target = target_p;
hdata.approved = !(is_chanop(msptr) || (chptr->mode.mode & MODE_FREEINVITE));
call_hook(can_invite_hook, &hdata); call_hook(can_invite_hook, &hdata);
if (hdata.approved) if (hdata.approved)
{
if (MyClient(target_p))
{ {
if (hdata.error) if (hdata.error)
sendto_one_numeric(source_p, hdata.approved, "%s", hdata.error); sendto_one_numeric(source_p, hdata.approved, "%s", hdata.error);
else if (hdata.approved == ERR_CHANOPRIVSNEEDED) else if (hdata.approved == ERR_CHANOPRIVSNEEDED)
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, parv[2]); me.name, source_p->name, parv[2]);
return;
add_reply_target(target_p, source_p);
} }
return;
} }
/* store invites when they could affect the ability to join /* store invites when they could affect the ability to join