From 4529f30dcea436613710781f4d70672df5394eb1 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 14 Jan 2024 21:02:39 -0800 Subject: [PATCH] switch from opt_outs.txt to new User.manual_opt_out property opt_outs.txt wasn't included in continuous deploy from Circle, so those deploys were ignoring ids in that file :/ --- .gitignore | 1 - common.py | 7 ------- models.py | 6 +++++- tests/test_models.py | 3 +-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 15057a6..91e4708 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ flask_secret_key /l /local* make_password -opt_outs.txt private_notes service_account_creds.json superfeedr_token diff --git a/common.py b/common.py index e818fef..562de30 100644 --- a/common.py +++ b/common.py @@ -66,13 +66,6 @@ DOMAIN_BLOCKLIST = ( 'twitter.com', ) -opt_outs = Path(__file__).parent / 'opt_outs.txt' -if opt_outs.exists(): - with opt_outs.open() as f: - OPT_OUT_IDS = util.load_file_lines(f) -else: - OPT_OUT_IDS = {'fake:bridgy-fed:test-opt-out'} - # populated in models.reset_protocol_properties SUBDOMAIN_BASE_URL_RE = None ID_FIELDS = ['id', 'object', 'actor', 'author', 'inReplyTo', 'url'] diff --git a/models.py b/models.py index b8c298c..75b0ec1 100644 --- a/models.py +++ b/models.py @@ -152,6 +152,10 @@ class User(StringIdModel, metaclass=ProtocolUserMeta): public_exponent = ndb.StringProperty() private_exponent = ndb.StringProperty() + # set to True for users who asked me to be opted out instead of putting + # #nobridge in their profile + manual_opt_out = ndb.BooleanProperty() + created = ndb.DateTimeProperty(auto_now_add=True) updated = ndb.DateTimeProperty(auto_now=True) @@ -314,7 +318,7 @@ class User(StringIdModel, metaclass=ProtocolUserMeta): https://github.com/snarfed/bridgy-fed/issues/666 """ - if self.key.id() in common.OPT_OUT_IDS: + if self.manual_opt_out: return 'opt-out' if not self.obj or not self.obj.as1: diff --git a/tests/test_models.py b/tests/test_models.py index f35d20c..e3856da 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -233,8 +233,7 @@ class UserTest(TestCase): }) self.assertEqual('opt-out', user.status) - # from opt_outs.txt - user = self.make_user('fake:bridgy-fed:test-opt-out', cls=Fake) + user = User(manual_opt_out=True) self.assertEqual('opt-out', user.status) def test_get_copy(self):