bug fix for opt out, handle HTML

pull/691/head
Ryan Barrett 2023-10-21 20:51:54 -07:00
rodzic b32045d494
commit 158200d9fd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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': '<a href="..." class="hashtag">#<span>nobridge</span></a>',
})
self.assertEqual('opt-out', user.status)