allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] allura git commit: [#8021] run spam checker on post/ticket/blog edits, and for admins/devs posts
Date Thu, 22 Dec 2016 17:32:07 GMT
Repository: allura
Updated Branches:
  refs/heads/master da54abd1a -> c780b9717


[#8021] run spam checker on post/ticket/blog edits, and for admins/devs posts


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/c780b971
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c780b971
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c780b971

Branch: refs/heads/master
Commit: c780b9717c0ba976b04bf832e5dbbc749da6bd4c
Parents: ca8b596
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon Dec 19 14:17:50 2016 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Dec 22 12:31:54 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py      | 1 +
 Allura/allura/model/discuss.py            | 4 +++-
 ForgeBlog/forgeblog/main.py               | 3 +++
 ForgeTracker/forgetracker/tracker_main.py | 6 ++++--
 4 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c780b971/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index d6ba1ff..509de41 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -298,6 +298,7 @@ class PostController(BaseController):
             self.post.edit_count = self.post.edit_count + 1
             self.post.last_edit_date = datetime.utcnow()
             self.post.last_edit_by_id = c.user._id
+            self.thread.is_spam(self.post)  # run spam checker, nothing to do with result
yet
             self.post.commit()
             g.director.create_activity(c.user, 'modified', self.post,
                                        target=self.post.thread.artifact or self.post.thread,

http://git-wip-us.apache.org/repos/asf/allura/blob/c780b971/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 874a888..f4ddd7d 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -286,10 +286,12 @@ class Thread(Artifact, ActivityObject):
 
     def is_spam(self, post):
         roles = [r.name for r in c.project.named_roles]
+        spammy = g.spam_checker.check(post.text, artifact=post, user=c.user)
         if c.user in c.project.users_with_role(*roles):
+            # always run the check, so it's logged.  But don't act on it for admins/developers
of their own project
             return False
         else:
-            return g.spam_checker.check(post.text, artifact=post, user=c.user)
+            return spammy
 
     def post(self, text, message_id=None, parent_id=None, notify=True,
              notification_text=None, timestamp=None, ignore_security=False,

http://git-wip-us.apache.org/repos/asf/allura/blob/c780b971/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 00e1c2a..8cb3cfe 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -408,6 +408,9 @@ class PostController(BaseController, FeedController):
             self.post.delete()
             flash('Post deleted', 'info')
             redirect(h.really_unicode(c.app.url).encode('utf-8'))
+        else:
+            g.spam_checker.check(kw['title'] + u'\n' + kw['text'], artifact=self.post,
+                                 user=c.user, content_type='blog-post')
         for k, v in kw.iteritems():
             setattr(self.post, k, v)
         self.post.commit()

http://git-wip-us.apache.org/repos/asf/allura/blob/c780b971/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 3227c4f..44053d9 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -933,8 +933,8 @@ class RootController(BaseController, FeedController):
             require_access(c.app, 'create')
             self.rate_limit(redir='.')
             ticket = TM.Ticket.new()
-            g.spam_checker.check(ticket_form['summary'] + u'\n' + ticket_form.get('description',
''), artifact=ticket,
-                                 user=c.user, content_type='ticket')
+        g.spam_checker.check(ticket_form['summary'] + u'\n' + ticket_form.get('description',
''), artifact=ticket,
+                             user=c.user, content_type='ticket')
         ticket.update(ticket_form)
         c.app.globals.invalidate_bin_counts()
         g.director.create_activity(c.user, 'created', ticket,
@@ -1464,6 +1464,8 @@ class TicketController(BaseController, FeedController):
     @require_post()
     def _update_ticket(self, post_data):
         require_access(self.ticket, 'update')
+        g.spam_checker.check(post_data.get('summary', '') + u'\n' + post_data.get('description',
''),
+                             artifact=self.ticket, user=c.user, content_type='ticket')
         changes = changelog()
         comment = post_data.pop('comment', None)
         labels = post_data.pop('labels', None) or []


Mime
View raw message