temporarily disable actually deleting Followers on AP Delete requests

mastodon.social sends Deletes for every Bridgy Fed account, all at basically the same time, and we have many Follower objects, so we have to do this table scan for each one, so the requests take a long time and end up spawning extra App Engine instances that we get billed for. and the Delete requests are almost never for followers we have. TODO: revisit this and do it right.
thib
Ryan Barrett 2020-10-11 08:32:55 -07:00
rodzic db75c0f555
commit dba533a14b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
5 zmienionych plików z 24 dodań i 9 usunięć

1
.gitignore vendored
Wyświetl plik

@ -5,4 +5,5 @@ datastore.dat*
/l
/local*
private_notes
service_account_creds.json
TAGS

Wyświetl plik

@ -18,8 +18,8 @@ Development
You'll need Python 3. Install the [Google Cloud SDK](https://cloud.google.com/sdk/gcloud/) (aka `gcloud`) with the `gcloud-appengine-python` and `gcloud-appengine-python-extras` [components](https://cloud.google.com/sdk/docs/components#additional_components). Then, run:
```sh
python3 -m venv local3
source local3/bin/activate
python3 -m venv local
source local/bin/activate
pip install -r requirements.txt
```

Wyświetl plik

@ -135,12 +135,21 @@ class InboxHandler(common.Handler):
return self.undo_follow(self.redirect_unwrap(activity))
elif type == 'Delete':
id = obj.get('id')
if isinstance(id, str):
# assume this is an actor
# https://github.com/snarfed/bridgy-fed/issues/63
for key in Follower.query().iter(keys_only=True):
if key.id().split(' ')[-1] == id:
key.delete()
# !!! temporarily disabled actually deleting Followers below because
# mastodon.social sends Deletes for every Bridgy Fed account, all at
# basically the same time, and we have many Follower objects, so we
# have to do this table scan for each one, so the requests take a
# long time and end up spawning extra App Engine instances that we
# get billed for. and the Delete requests are almost never for
# followers we have. TODO: revisit this and do it right.
# if isinstance(id, str):
# # assume this is an actor
# # https://github.com/snarfed/bridgy-fed/issues/63
# for key in Follower.query().iter(keys_only=True):
# if key.id().split(' ')[-1] == id:
# key.delete()
return
# fetch actor if necessary so we have name, profile photo, etc

Wyświetl plik

@ -1,7 +1,11 @@
# https://cloud.google.com/appengine/docs/standard/python/config/appref
# application: bridgy-federated
# pycrypto doesn't support python 3.8 (due to time.clock). should switch to
# pycryptodome.
runtime: python37
# default_expiration: 1h
# https://cloud.google.com/appengine/docs/standard/python3/runtime#entrypoint_best_practices

Wyświetl plik

@ -422,4 +422,5 @@ class ActivityPubTest(testutil.TestCase):
body=json_dumps(DELETE).encode())
self.assertEqual(200, got.status_int)
self.assertEqual([other], Follower.query().fetch())
# TODO: bring back
# self.assertEqual([other], Follower.query().fetch())