diff --git a/models.py b/models.py index 1fb9d9e2..a516444a 100644 --- a/models.py +++ b/models.py @@ -15,6 +15,7 @@ from Crypto.PublicKey import RSA from flask import g, request from google.cloud import ndb from granary import as1, as2, bluesky, microformats2 +from granary.source import html_to_text from oauth_dropins.webutil import util from oauth_dropins.webutil.appengine_info import DEBUG from oauth_dropins.webutil.flask_util import error @@ -335,9 +336,9 @@ class User(StringIdModel, metaclass=ProtocolUserMeta): return None for field in 'summary', 'displayName': - val = self.obj.as1.get(field) + text = html_to_text(self.obj.as1.get(field, '')) for tag in OPT_OUT_TAGS: - if val and tag in val: + if tag in text: return 'opt-out' return None diff --git a/tests/test_models.py b/tests/test_models.py index f5a35644..3a338d6e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -226,7 +226,8 @@ class UserTest(TestCase): user.obj.our_as1.update({ 'summary': '🤷', - 'displayName': 'well #nobridge yeah', + # This is Mastodon's HTML around hashtags + 'displayName': '#nobridge', }) self.assertEqual('opt-out', user.status)