mirror of
https://github.com/osmarks/ngircd.git
synced 2025-07-05 11:22:49 +00:00
Channel lists: Fix duplicate check and error messages
- Check correct list for duplicates when adding items. - Don't generate any messages when adding duplicates or removing non-existing items (this is how ircd-seven and ircu behave). - Code cleanup: Add_Ban_Invite(), Del_Ban_Invite().
This commit is contained in:
parent
78a3b4c7d6
commit
81cc5f82b5
@ -831,12 +831,21 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
|
|||||||
} /* IRC_AWAY */
|
} /* IRC_AWAY */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entries to channel ban and invite lists.
|
||||||
|
*
|
||||||
|
* @param what Can be 'I' for invite or 'b' for ban list.
|
||||||
|
* @param Prefix The originator of the command.
|
||||||
|
* @param Client The sender of the command.
|
||||||
|
* @param Channel The channel of which the list should be modified.
|
||||||
|
* @param Pattern The pattern to add to the list.
|
||||||
|
* @return CONNECTED or DISCONNECTED.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
Add_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)
|
Add_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
|
||||||
|
const char *Pattern)
|
||||||
{
|
{
|
||||||
const char *mask;
|
const char *mask;
|
||||||
bool already;
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Channel != NULL);
|
assert(Channel != NULL);
|
||||||
@ -845,29 +854,37 @@ Add_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const
|
|||||||
|
|
||||||
mask = Lists_MakeMask(Pattern);
|
mask = Lists_MakeMask(Pattern);
|
||||||
|
|
||||||
already = Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask);
|
if (what == 'I') {
|
||||||
if (!already) {
|
if (Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask))
|
||||||
if (what == 'I')
|
|
||||||
ret = Channel_AddInvite(Channel, mask, false);
|
|
||||||
else
|
|
||||||
ret = Channel_AddBan(Channel, mask);
|
|
||||||
if (!ret)
|
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
}
|
if (!Channel_AddInvite(Channel, mask, false))
|
||||||
if (already && (Client_Type(Prefix) == CLIENT_SERVER))
|
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
|
|
||||||
if (what == 'I')
|
|
||||||
return Send_ListChange("+I", Prefix, Client, Channel, mask);
|
return Send_ListChange("+I", Prefix, Client, Channel, mask);
|
||||||
|
} else {
|
||||||
|
if (Lists_CheckDupeMask(Channel_GetListBans(Channel), mask))
|
||||||
|
return CONNECTED;
|
||||||
|
if (!Channel_AddBan(Channel, mask))
|
||||||
|
return CONNECTED;
|
||||||
return Send_ListChange("+b", Prefix, Client, Channel, mask);
|
return Send_ListChange("+b", Prefix, Client, Channel, mask);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete entries from channel ban and invite lists.
|
||||||
|
*
|
||||||
|
* @param what Can be 'I' for invite or 'b' for ban list.
|
||||||
|
* @param Prefix The originator of the command.
|
||||||
|
* @param Client The sender of the command.
|
||||||
|
* @param Channel The channel of which the list should be modified.
|
||||||
|
* @param Pattern The pattern to add to the list.
|
||||||
|
* @return CONNECTED or DISCONNECTED.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)
|
Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
|
||||||
|
const char *Pattern)
|
||||||
{
|
{
|
||||||
const char *mask;
|
const char *mask;
|
||||||
struct list_head *list;
|
|
||||||
|
|
||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Channel != NULL);
|
assert(Channel != NULL);
|
||||||
@ -876,17 +893,20 @@ Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const
|
|||||||
|
|
||||||
mask = Lists_MakeMask(Pattern);
|
mask = Lists_MakeMask(Pattern);
|
||||||
|
|
||||||
if (what == 'I')
|
if (what == 'I') {
|
||||||
list = Channel_GetListInvites(Channel);
|
if (!Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask))
|
||||||
else
|
return CONNECTED;
|
||||||
list = Channel_GetListBans(Channel);
|
Lists_Del(Channel_GetListInvites(Channel), mask);
|
||||||
|
|
||||||
Lists_Del(list, mask);
|
|
||||||
if (what == 'I')
|
|
||||||
return Send_ListChange( "-I", Prefix, Client, Channel, mask );
|
return Send_ListChange( "-I", Prefix, Client, Channel, mask );
|
||||||
|
} else {
|
||||||
|
if (!Lists_CheckDupeMask(Channel_GetListBans(Channel), mask))
|
||||||
|
return CONNECTED;
|
||||||
|
Lists_Del(Channel_GetListBans(Channel), mask);
|
||||||
return Send_ListChange( "-b", Prefix, Client, Channel, mask );
|
return Send_ListChange( "-b", Prefix, Client, Channel, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
Send_ListChange(const char *Mode, CLIENT *Prefix, CLIENT *Client,
|
Send_ListChange(const char *Mode, CLIENT *Prefix, CLIENT *Client,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user