/accept list should track nick changes when you share channels (#96)

* move has_common_channel to s_user.c

* don't remove clients from /accept on NICK when there's a common channel

Co-authored-by: Ed Kellett <e@kellett.im>
This commit is contained in:
jess 2021-01-25 05:00:34 +00:00 committed by GitHub
parent 0ba1da5910
commit fdd4857c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 19 deletions

View file

@ -54,3 +54,5 @@ extern void construct_umodebuf(void);
extern void oper_up(struct Client *, struct oper_conf *);
#endif
extern bool has_common_channel(struct Client *source_p, struct Client *target_p);

View file

@ -1644,3 +1644,20 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use
del_all_accepts(target_p);
}
}
bool
has_common_channel(struct Client *source_p, struct Client *target_p)
{
rb_dlink_node *ps, *pt;
struct membership *ms, *mt;
struct Channel *chptr;
ITER_COMM_CHANNELS(ps, pt, source_p->user->channel.head, target_p->user->channel.head, ms, mt, chptr)
{
if (ms != NULL && mt != NULL)
return true;
}
return false;
}

View file

@ -712,8 +712,11 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
{
target_p = ptr->data;
rb_dlinkFindDestroy(source_p, &target_p->localClient->allow_list);
rb_dlinkDestroy(ptr, &source_p->on_allow_list);
if (!has_common_channel(source_p, target_p))
{
rb_dlinkFindDestroy(source_p, &target_p->localClient->allow_list);
rb_dlinkDestroy(ptr, &source_p->on_allow_list);
}
}
snprintf(note, sizeof(note), "Nick: %s", nick);
@ -729,6 +732,8 @@ static void
change_remote_nick(struct Client *client_p, struct Client *source_p,
time_t newts, const char *nick, int dosend)
{
struct Client *target_p;
rb_dlink_node *ptr, *next_ptr;
struct nd_entry *nd;
int samenick = irccmp(source_p->name, nick) ? 0 : 1;
hook_cdata hook_info;
@ -771,7 +776,16 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
monitor_signon(source_p);
/* remove all accepts pointing to the client */
del_all_accepts(source_p);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, source_p->on_allow_list.head)
{
target_p = ptr->data;
if (!has_common_channel(source_p, target_p))
{
rb_dlinkFindDestroy(source_p, &target_p->localClient->allow_list);
rb_dlinkDestroy(ptr, &source_p->on_allow_list);
}
}
}
static void

View file

@ -87,22 +87,6 @@ um_callerid_moddeinit(void)
static const char um_callerid_desc[] =
"Provides usermodes +g and +G which restrict messages from unauthorized users.";
static bool
has_common_channel(struct Client *source_p, struct Client *target_p)
{
rb_dlink_node *ps, *pt;
struct membership *ms, *mt;
struct Channel *chptr;
ITER_COMM_CHANNELS(ps, pt, source_p->user->channel.head, target_p->user->channel.head, ms, mt, chptr)
{
if (ms != NULL && mt != NULL)
return true;
}
return false;
}
static bool
allow_message(struct Client *source_p, struct Client *target_p)
{