[notification] avoid using InternalManager when we've got a CWUser
This will avoid potential information leak due to missed security restriction
and is more compatible with legacy code (pb encountered in some client code).
Closes #10294761
--- a/cubicweb/sobjects/notification.py Wed Jan 27 08:35:51 2016 +0100
+++ b/cubicweb/sobjects/notification.py Tue Jan 26 18:04:00 2016 +0100
@@ -50,9 +50,7 @@
mode = self._cw.vreg.config['default-recipients-mode']
if mode == 'users':
execute = self._cw.execute
- dests = [(u.cw_adapt_to('IEmailable').get_email(),
- u.property_value('ui.language'))
- for u in execute(self.user_rql, build_descr=True).entities()]
+ dests = list(execute(self.user_rql, build_descr=True).entities())
elif mode == 'default-dest-addrs':
lang = self._cw.vreg.property_value('ui.language')
dests = zip(self._cw.vreg.config['default-dest-addrs'], repeat(lang))
--- a/cubicweb/sobjects/test/unittest_notification.py Wed Jan 27 08:35:51 2016 +0100
+++ b/cubicweb/sobjects/test/unittest_notification.py Tue Jan 26 18:04:00 2016 +0100
@@ -35,7 +35,7 @@
self.set_option('default-recipients-mode', 'none')
self.assertEqual(finder.recipients(), [])
self.set_option('default-recipients-mode', 'users')
- self.assertEqual(finder.recipients(), [(u'admin@logilab.fr', 'fr')])
+ self.assertEqual(finder.recipients(), [req.user])
self.set_option('default-recipients-mode', 'default-dest-addrs')
self.set_option('default-dest-addrs', 'abcd@logilab.fr, efgh@logilab.fr')
self.assertEqual(list(finder.recipients()),