mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made sure chanop capability supercedes everything else.
This commit is contained in:
parent
d3a81688fa
commit
5a15783e7a
@ -564,17 +564,18 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
#debug.printf('isChannelCapability true, user found too.')
|
||||
(channel, capability) = fromChannelCapability(capability)
|
||||
try:
|
||||
chanop = makeChannelCapability(channel, 'op')
|
||||
if u.checkCapability(chanop):
|
||||
return _x(capability, True)
|
||||
except KeyError:
|
||||
pass
|
||||
c = channels.getChannel(channel)
|
||||
#debug.printf('channel found')
|
||||
if capability in c.capabilities:
|
||||
#debug.printf('capability in c.capabilities')
|
||||
return c.checkCapability(capability)
|
||||
else:
|
||||
#debug.printf('capability not in c.capabilities')
|
||||
return _x(capability, c.defaultAllow)
|
||||
except KeyError:
|
||||
#debug.printf('no such channel %s' % channel)
|
||||
pass
|
||||
if capability in conf.defaultCapabilities:
|
||||
#debug.printf('capability in conf.defaultCapabilities')
|
||||
return True
|
||||
|
@ -35,6 +35,7 @@ import os
|
||||
import unittest
|
||||
|
||||
import conf
|
||||
import debug
|
||||
import ircdb
|
||||
import ircutils
|
||||
|
||||
@ -296,6 +297,7 @@ class CheckCapabilityTestCase(unittest.TestCase):
|
||||
anticap = ircdb.makeAntiCapability(cap)
|
||||
chancap = ircdb.makeChannelCapability(channel, cap)
|
||||
antichancap = ircdb.makeAntiCapability(chancap)
|
||||
chanop = ircdb.makeChannelCapability(channel, 'op')
|
||||
channelnothing = ircdb.IrcChannel()
|
||||
channelcap = ircdb.IrcChannel()
|
||||
channelcap.addCapability(cap)
|
||||
@ -393,6 +395,18 @@ class CheckCapabilityTestCase(unittest.TestCase):
|
||||
self.failUnless(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.failIf(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
|
||||
def testChanOpCountsAsEverything(self):
|
||||
self.channels.setChannel(self.channel, self.channelanticap)
|
||||
id = self.users.getUserId('nothing')
|
||||
u = self.users.getUser(id)
|
||||
u.addCapability(self.chanop)
|
||||
self.users.setUser(id, u)
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.channelnothing.defaultAllow = not self.channelnothing.defaultAllow
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
|
||||
def testAntiChanFoo(self):
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
self.failIf(self.checkCapability(self.antichanfoo, self.chancap))
|
||||
|
Loading…
Reference in New Issue
Block a user