Switch to unified view

a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
...
...
234
            link = p.url_paginated()
234
            link = p.url_paginated()
235
        if self.ref:
235
        if self.ref:
236
            Feed.post(self.primary(), title=p.subject, description=p.text, link=link)
236
            Feed.post(self.primary(), title=p.subject, description=p.text, link=link)
237
        return p
237
        return p
238
238
239
    def check_spam(self, post):
239
    def is_spam(self, post):
240
        result = True
240
        if c.user in c.project.users_with_role('Admin', 'Developer'):
241
        for role in c.user.project_role(c.project).roles:
242
            if ((ProjectRole.query.get(_id=role).name == 'Admin') or
243
                    (ProjectRole.query.get(_id=role).name == 'Developer')):
244
                return True
241
            return False
245
242
        else:
246
        if g.spam_checker.check('%s\n%s' % (post.subject, post.text), artifact=post, user=c.user):
243
            return g.spam_checker.check('%s\n%s' % (post.subject, post.text), artifact=post, user=c.user)
247
            result = False
248
        return result
249
250
244
251
    def post(self, text, message_id=None, parent_id=None,
245
    def post(self, text, message_id=None, parent_id=None,
252
             timestamp=None, ignore_security=False, **kw):
246
             timestamp=None, ignore_security=False, **kw):
253
        if not ignore_security:
247
        if not ignore_security:
254
            require_access(self, 'post')
248
            require_access(self, 'post')
...
...
269
        if timestamp is not None:
263
        if timestamp is not None:
270
            kwargs['timestamp'] = timestamp
264
            kwargs['timestamp'] = timestamp
271
        if message_id is not None:
265
        if message_id is not None:
272
            kwargs['_id'] = message_id
266
            kwargs['_id'] = message_id
273
        post = self.post_class()(**kwargs)
267
        post = self.post_class()(**kwargs)
274
275
        if ignore_security or self.check_spam(post):
268
        if ignore_security or not self.is_spam(post):
276
            log.info('Auto-approving message from %s', c.user.username)
269
            log.info('Auto-approving message from %s', c.user.username)
277
            file_info = kw.get('file_info', None)
270
            file_info = kw.get('file_info', None)
278
            post.approve(file_info, notify=kw.get('notify', True))
271
            post.approve(file_info, notify=kw.get('notify', True))
279
        else:
272
        else:
280
            self.notify_moderators(post)
273
            self.notify_moderators(post)