forked from lesderid/salty-ircd
Check if the user is allowed to send to a channel
This commit is contained in:
parent
f7edfa9e8f
commit
fd8a9aafe7
|
@ -324,4 +324,22 @@ class Channel
|
|||
{
|
||||
return members.canFind(connection) || !modes.canFind('s') && !modes.canFind('p');
|
||||
}
|
||||
|
||||
bool canReceiveMessagesFromUser(Connection connection)
|
||||
{
|
||||
if(modes.canFind('n') && !members.canFind(connection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(modes.canFind('m') && nickPrefix(connection).empty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(maskLists['b'].any!(m => connection.matchesMask(m)) && !maskLists['e'].any!(m => connection.matchesMask(m)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,10 +397,15 @@ class Connection
|
|||
|
||||
if(Server.isValidChannelName(target))
|
||||
{
|
||||
if(!_server.canFindChannelByName(target))
|
||||
auto channelRange = _server.findChannelByName(target);
|
||||
if(channelRange.empty)
|
||||
{
|
||||
sendErrNoSuchNick(target);
|
||||
}
|
||||
else if(!channelRange[0].canReceiveMessagesFromUser(this))
|
||||
{
|
||||
send(Message(_server.name, "404", [nick, target, "Cannot send to channel"], true));
|
||||
}
|
||||
else
|
||||
{
|
||||
_server.privmsgToChannel(this, target, text);
|
||||
|
|
Loading…
Reference in New Issue