allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [10/11] allura git commit: [#8082] do spam check (but no action) on tickets and blog posts, like already done for wiki pages
Date Mon, 02 May 2016 18:52:24 GMT
[#8082] do spam check (but no action) on tickets and blog posts, like already done for wiki
pages


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

Branch: refs/heads/db/8082
Commit: 639989e06f96e9d0dd62ff4dc6e4f89bf64b8e97
Parents: 8506475
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon May 2 14:38:35 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon May 2 14:48:38 2016 -0400

----------------------------------------------------------------------
 Allura/allura/lib/spam/akismetfilter.py           | 3 +--
 ForgeBlog/forgeblog/main.py                       | 2 ++
 ForgeTracker/forgetracker/tracker_main.py         | 2 ++
 ForgeWiki/forgewiki/tests/functional/test_root.py | 2 +-
 ForgeWiki/forgewiki/wiki_main.py                  | 2 +-
 5 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/639989e0/Allura/allura/lib/spam/akismetfilter.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/spam/akismetfilter.py b/Allura/allura/lib/spam/akismetfilter.py
index 6f199d0..e5ef1b8 100644
--- a/Allura/allura/lib/spam/akismetfilter.py
+++ b/Allura/allura/lib/spam/akismetfilter.py
@@ -81,7 +81,6 @@ class AkismetSpamFilter(SpamFilter):
         return kw
 
     def check(self, text, artifact=None, user=None, content_type='comment', **kw):
-        log_msg = text
         res = self.service.comment_check(text,
                                          data=self.get_data(text=text,
                                                             artifact=artifact,
@@ -90,7 +89,7 @@ class AkismetSpamFilter(SpamFilter):
                                                             request=request,
                                                             ),
                                          build_data=False)
-        log.info("spam=%s (akismet): %s" % (str(res), log_msg))
+        log.info("spam=%s (akismet): %s" % (str(res), artifact.url() if artifact else text))
         return res
 
     def submit_spam(self, text, artifact=None, user=None, content_type='comment'):

http://git-wip-us.apache.org/repos/asf/allura/blob/639989e0/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index f093df0..a200ea9 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -308,6 +308,8 @@ class RootController(BaseController, FeedController):
         require_access(c.app, 'write')
         rate_limit()
         post = BM.BlogPost.new(**kw)
+        g.spam_checker.check(kw['title'] + u'\n' + kw['text'], artifact=post,
+                             user=c.user, content_type='blog-post')
         redirect(h.really_unicode(post.url()).encode('utf-8'))
 
     @with_trailing_slash

http://git-wip-us.apache.org/repos/asf/allura/blob/639989e0/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 50ea154..91f354d 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -937,6 +937,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')
         ticket.update(ticket_form)
         c.app.globals.invalidate_bin_counts()
         g.director.create_activity(c.user, 'created', ticket,

http://git-wip-us.apache.org/repos/asf/allura/blob/639989e0/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index fbe529f..0402b40 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -391,7 +391,7 @@ class TestRootController(TestController):
                 'text': 'sometext',
                 'labels': '',
                 'viewable_by-0.id': 'all'})
-        assert_equal(spam_checker.check.call_args[0][0], 'sometext')
+        assert_equal(spam_checker.check.call_args[0][0], u'tést\nsometext')
         assert 'tést' in response
 
     def test_page_label_unlabel(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/639989e0/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 2350509..cc0e3a4 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -745,7 +745,7 @@ class PageController(BaseController, FeedController):
         else:
             self.page.labels = []
         self.page.commit()
-        g.spam_checker.check(text, artifact=self.page,
+        g.spam_checker.check(title + u'\n' + text, artifact=self.page,
                              user=c.user, content_type='wiki')
         g.director.create_activity(c.user, activity_verb, self.page,
                                    related_nodes=[c.project], tags=['wiki'])


Mime
View raw message