Skip to content

Commit a487451

Browse files
committed
Todo: Add allowThirdpartyReader config variable.
1 parent 61ec5f7 commit a487451

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

plugins/Todo/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ def configure(advanced):
4646
# conf.registerGlobalValue(Todo, 'someConfigVariableName',
4747
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
4848

49+
conf.registerGlobalValue(Todo, 'allowThirdpartyReader',
50+
registry.Boolean(False, _("""Determines whether users can read the
51+
todo-list of another user.""")))
4952

5053
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

plugins/Todo/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def todo(self, irc, msg, args, user, taskid):
142142
u = ircdb.users.getUser(msg.prefix)
143143
except KeyError:
144144
u = None
145+
if u != user and not self.registryValue('allowThirdpartyReader'):
146+
irc.error(_('You are not allowed to see other users todo-list.'))
147+
return
145148
# List the active tasks for the given user
146149
if not taskid:
147150
try:

plugins/Todo/test.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from supybot.test import *
3131

3232
class TodoTestCase(PluginTestCase):
33-
plugins = ('Todo', 'User')
33+
plugins = ('Todo', 'User', 'Config')
3434
_user1 = 'foo!bar@baz'
3535
_user2 = 'bar!foo@baz'
3636
def setUp(self):
@@ -66,6 +66,17 @@ def testTodo(self):
6666
self.assertNotError('todo setpriority 1 100')
6767
self.assertNotError('todo setpriority 2 10')
6868
self.assertRegexp('todo', '#2: moo and #1: wash my car')
69+
# Check permissions
70+
self.prefix = self._user2
71+
self.assertError('todo tester')
72+
self.assertNotRegexp('todo tester', 'task id')
73+
self.prefix = self._user1
74+
self.assertNotError('todo tester')
75+
self.assertNotError('config plugins.Todo.allowThirdpartyReader True')
76+
self.prefix = self._user2
77+
self.assertNotError('todo tester')
78+
self.prefix = self._user1
79+
self.assertNotError('todo tester')
6980

7081
def testAddtodo(self):
7182
self.assertNotError('todo add code a new plugin')

0 commit comments

Comments
 (0)