Repository: internetarchive/openlibrary

Issue:
Extend admin spam checking functionality to people profile pages
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
People profile pages are a common home for spam on OL.  Spam has numerous downsides, including damaged patron trust and potentially directing our patrons to malicious sites.

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->
OL admins should have the ability to prevent spam from being added to people profiles like they do for other areas of OL.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
The existing spam checking functionality should be extended to people profile pages.

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->
@mekarpeles @cdrini @cclauss 


Discussion:

Resolving patch:
diff --git a/openlibrary/plugins/upstream/addbook.py b/openlibrary/plugins/upstream/addbook.py
--- a/openlibrary/plugins/upstream/addbook.py
+++ b/openlibrary/plugins/upstream/addbook.py
@@ -884,20 +884,6 @@ def process_input(self, i):
             return author
 
 
-class edit(core.edit):
-    """Overwrite ?m=edit behaviour for author, book and work pages."""
-    def GET(self, key):
-        page = web.ctx.site.get(key)
-
-        if web.re_compile('/(authors|books|works)/OL.*').match(key):
-            if page is None:
-                raise web.seeother(key)
-            else:
-                raise web.seeother(page.url(suffix="/edit"))
-        else:
-            return core.edit.GET(self, key)
-
-
 class daisy(delegate.page):
     path = "(/books/.*)/daisy"
 
diff --git a/openlibrary/plugins/upstream/code.py b/openlibrary/plugins/upstream/code.py
--- a/openlibrary/plugins/upstream/code.py
+++ b/openlibrary/plugins/upstream/code.py
@@ -11,6 +11,7 @@
 import web
 
 from infogami import config
+from infogami.core import code as core
 from infogami.infobase import client
 from infogami.utils import delegate, app, types
 from infogami.utils.view import public, safeint, render
@@ -20,6 +21,7 @@
 from openlibrary import accounts
 
 from openlibrary.plugins.upstream import addbook, covers, merge_authors, models, utils
+from openlibrary.plugins.upstream import spamcheck
 from openlibrary.plugins.upstream import borrow, recentchanges  # TODO: unused imports?
 from openlibrary.plugins.upstream.utils import render_component
 
@@ -32,6 +34,28 @@ def GET(self):
         host = 'https://%s' % web.ctx.host if 'openlibrary.org' in web.ctx.host else ''
         raise web.seeother(host + '/static' + web.ctx.path)
 
+
+class edit(core.edit):
+    """Overwrite ?m=edit behaviour for author, book, work, and people pages."""
+    def GET(self, key):
+        page = web.ctx.site.get(key)
+
+        if web.re_compile('/(authors|books|works)/OL.*').match(key):
+            if page is None:
+                raise web.seeother(key)
+            else:
+                raise web.seeother(page.url(suffix="/edit"))
+        else:
+            return core.edit.GET(self, key)
+
+    def POST(self, key):
+        if web.re_compile('/(people/[^/]+)').match(key) and spamcheck.is_spam():
+            return render_template('message.html', 'Oops',
+                                   'Something went wrong. Please try again later.')
+        return core.edit.POST(self, key)
+
+
+
 # handlers for change photo and change cover
 
 class change_cover(delegate.mode):


Test patch: