Wykres commitów

57 Commity (main)

Autor SHA1 Wiadomość Data
Ryan Barrett 11eb082190
tighten common.unwrap so it doesn't remove protocol bot user URLs
...like https://bsky.brid.gy/ . this hopefully fixes following bot users in eg AP to enable protocols.
2024-04-23 12:00:39 -07:00
Ryan Barrett b9551c4de7
adjust Web.owns_id to say it owns protocol bot user domains but not their pages
eg bsky.brid.gy True, https://bsky.brid.gy/ True, https://bsky.brid.gy/foo False.

also move our internal synthetic UI-initiated follow ids from https://fed.brid.gy/web/... to under the user's own domain. hopefully this won't break anything 🤞
2024-04-22 11:58:01 -07:00
Ryan Barrett 95e46c5ebb
Revert "cache outbound HTTP request responses, locally to each inbound request"
This reverts commit 30debfc8fa.

seemed promising, but broke in production. Saw a lot of `IncompleteRead`s on both GETs and POSTs. Rolled back for now.

```
('Connection broken: IncompleteRead(9172 bytes read, -4586 more expected)', IncompleteRead(9172 bytes read, -4586 more expected))
...
File "oauth_dropins/webutil/util.py", line 1673, in call
  resp = getattr((session or requests), fn)(url, *args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 102, in get
  return self.request('GET', url, params=params, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 158, in request
  return super().request(method, url, *args, headers=headers, **kwargs)  # type: ignore
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests/sessions.py", line 589, in request
  resp = self.send(prep, **send_kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 205, in send
  response = self._send_and_cache(request, actions, cached_response, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 233, in _send_and_cache
  self.cache.save_response(response, actions.cache_key, actions.expires)
File "requests_cache/backends/base.py", line 89, in save_response
  cached_response = CachedResponse.from_response(response, expires=expires)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/models/response.py", line 102, in from_response
  obj.raw = CachedHTTPResponse.from_response(response)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/models/raw_response.py", line 69, in from_response
  _ = response.content  # This property reads, decodes, and stores response content
      ^^^^^^^^^^^^^^^^
File "requests/models.py", line 899, in content
  self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests/models.py", line 818, in generate
  raise ChunkedEncodingError(e)
```
2024-03-11 15:31:30 -07:00
Ryan Barrett 30debfc8fa
cache outbound HTTP request responses, locally to each inbound request
using requests-cache. pretty straightforward! for #588
2024-03-08 12:34:49 -08:00
Ryan Barrett 6a63820cd8
tighten Object.owns_id to reject blocklisted domains
fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federated
2024-02-08 14:41:15 -08:00
Ryan Barrett fcef6c21ab
Revert "heuristic: assume no AP actor id is the root path on its host"
This reverts commit b7e890b4bb.

it was a nice idea, but we're now hitting AP actor ids that are the root path on their host. this is evidently how microblog.pub does AP; 0x3b0b's site https://bw3.dev/ is an example. general info on https://docs.microblog.pub/user_guide.html#activitypub but not this specifically.

fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federated
2024-01-26 12:59:54 -08:00
Ryan Barrett 8ab09511bd
bug fix for following from web UI with custom username
thanks again for reporting @campegg!
2024-01-26 06:52:03 -08:00
Ryan Barrett 3bcef0d37d
follow UI: specific error message for trying to follow bridged accounts
thanks for the nudge @campegg!
2024-01-25 17:05:26 -08:00
Ryan Barrett 4bcf6b463f
web follow bug fix: error gracefully on BF user addresses
fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federated
2024-01-22 08:43:33 -08:00
Ryan Barrett 3e49fafd0a
unfollow UI: bug fix for when indieauth home page fetch fails
fixes https://console.cloud.google.com/errors/detail/CIb-6vLIioHJaw;time=P30D?project=bridgy-federated
2024-01-19 11:33:58 -08:00
Ryan Barrett a832a4edf6
follow UI: error on bridged accounts
also make ActivityPub.owns_handle return False for bridged accounts

fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federated
2024-01-15 07:57:03 -08:00
Ryan Barrett afc2511e62
refactor follow/unfollow web UI to use Protocol.receive 2023-12-06 10:11:36 -08:00
Ryan Barrett 520b2fd3b0
User.ap_address() => handle_as(ActivityPub) 2023-11-29 21:06:55 -08:00
Ryan Barrett 4d095fa3d9
misc cleanup
* remove obsolete TODOs, commented out code
* remove obsolete circular imports of per-protocol modules
* minimize Object put in Protocol.load
* remove duplicated Protocol.load tests in test_activitypub
* re-enable rest of ActivityPubUtilsTest.test_postprocess_as2_idempotent
* drop default cls=Web in TestCase.make_user
2023-11-15 14:23:08 -08:00
Ryan Barrett aa5c6a396e
ActivityPub: translate ids in convert 2023-11-03 15:11:21 -07:00
Ryan Barrett ca8b7484c0
drop User.as2, Object.as_as2, switch callers to Protocol.convert 2023-10-25 13:28:01 -07:00
Ryan Barrett 6a867ca2c4
update for granary.as2's new PropertyValue attachment handling
snarfed/granary@20d6c3f065
2023-10-24 16:02:16 -07:00
Ryan Barrett fe3a9b693c
User.get_or_create: load user profile object, fetch if it doesn't exist 2023-10-19 15:01:19 -07:00
Ryan Barrett 4f7e394c6e
AP: add #key fragment to publicKey.id so it's not the same as actor id
thanks for the nudge @HelgeKrueger!
2023-08-26 09:21:53 -07:00
Ryan Barrett 9daa8f36eb
AP follow/unfollow UI: handle followees with composite url objects
ie with namedprofile links

fixes https://console.cloud.google.com/errors/detail/CKmLytj-nPv9RQ;time=P30D?project=bridgy-federated
2023-08-26 07:49:27 -07:00
Ryan Barrett 62ba627bc9
bug fix for interactive follow with followee Object without as2
fixes https://console.cloud.google.com/errors/detail/CIeL-MyNk9z5LQ;time=P30D?project=bridgy-federated , https://console.cloud.google.com/errors/detail/COLs4IvxloWVUg;time=P30D?project=bridgy-federated
2023-08-01 09:47:32 -07:00
Ryan Barrett 58a8e28040
follow UI: handle composite url values
fixes https://console.cloud.google.com/errors/detail/CKmLytj-nPv9RQ;time=P30D?project=bridgy-federated
2023-07-14 17:45:49 -07:00
Ryan Barrett ab1c28ee4d
noop, lint fixes from flake8
remaining:

$ flake8 --extend-ignore=E501 *.py tests/*.py
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details
activitypub.py:15:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
activitypub.py:36:1: F401 'web' imported but unused
activitypub.py:48:1: E302 expected 2 blank lines, found 1
activitypub.py:51:9: F811 redefinition of unused 'web' from line 36
app.py:6:1: F401 'flask_app.app' imported but unused
app.py:9:1: F401 'activitypub' imported but unused
app.py:9:1: F401 'convert' imported but unused
app.py:9:1: F401 'follow' imported but unused
app.py:9:1: F401 'pages' imported but unused
app.py:9:1: F401 'redirect' imported but unused
app.py:9:1: F401 'superfeedr' imported but unused
app.py:9:1: F401 'ui' imported but unused
app.py:9:1: F401 'webfinger' imported but unused
app.py:9:1: F401 'web' imported but unused
app.py:9:1: F401 'xrpc_actor' imported but unused
app.py:9:1: F401 'xrpc_feed' imported but unused
app.py:9:1: F401 'xrpc_graph' imported but unused
app.py:9:19: E401 multiple imports on one line
models.py:19:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
models.py:364:31: E114 indentation is not a multiple of four (comment)
models.py:364:31: E116 unexpected indentation (comment)
protocol.py:17:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
redirect.py:26:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
web.py:18:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
webfinger.py:13:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
webfinger.py:110:13: E122 continuation line missing indentation or outdented
webfinger.py:111:13: E122 continuation line missing indentation or outdented
webfinger.py:131:13: E122 continuation line missing indentation or outdented
webfinger.py:132:13: E122 continuation line missing indentation or outdented
webfinger.py:133:13: E122 continuation line missing indentation or outdented
webfinger.py:134:13: E122 continuation line missing indentation or outdented
tests/__init__.py:2:1: F401 'oauth_dropins.webutil.tests' imported but unused
tests/test_follow.py:11:1: F401 'oauth_dropins.webutil.util.json_dumps' imported but unused
tests/test_follow.py:14:1: F401 '.testutil.Fake' imported but unused
tests/test_models.py:156:15: E122 continuation line missing indentation or outdented
tests/test_models.py:157:15: E122 continuation line missing indentation or outdented
tests/test_models.py:158:11: E122 continuation line missing indentation or outdented
tests/test_web.py:12:1: F401 'oauth_dropins.webutil.util.json_dumps' imported but unused
tests/test_web.py:17:1: F401 '.testutil' imported but unused
tests/test_web.py:1513:13: E128 continuation line under-indented for visual indent
tests/test_web.py:1514:9: E124 closing bracket does not match visual indentation
tests/testutil.py:106:1: E402 module level import not at top of file
tests/testutil.py:107:1: E402 module level import not at top of file
tests/testutil.py:108:1: E402 module level import not at top of file
tests/testutil.py:109:1: E402 module level import not at top of file
tests/testutil.py:110:1: E402 module level import not at top of file
tests/testutil.py:301:24: E203 whitespace before ':'
tests/testutil.py:301:25: E701 multiple statements on one line (colon)
tests/testutil.py:301:25: E231 missing whitespace after ':'
2023-06-20 11:29:31 -07:00
Ryan Barrett d3c4415cd3
migrate User.actor_as2 to obj key pointing to Object
for #547
2023-06-15 21:23:31 -07:00
Ryan Barrett bbcb8de44a
noop test refactoring: finally unify request context push/pop into testutil 2023-06-15 15:09:03 -07:00
Ryan Barrett c98ab3f2d5
AP users: Object schema change, domains => users
also for AP => wm, only try to send webmentions to domains that we already have an existing Web user for. the vast majority of targets are fediverse URLs, and we were trying to send them all wms, ie at least running wm discovery and finding nothing. harmless, but a waste.
2023-06-09 12:56:45 -07:00
Ryan Barrett 7f6cc61683
improve domain validation for Web key ids, normalize to lower case 2023-06-09 10:58:28 -07:00
Ryan Barrett afbb453043
AP users: finish migrating follow.py to Follower schema with new from/to
for #512, fixes https://console.cloud.google.com/errors/detail/CPn404XJ2rC6rAE;time=P30D?project=bridgy-federated
2023-06-07 23:51:41 -07:00
Ryan Barrett 9cb8c1f9f2
AP users: start migrating Follower from string domains/ids to User keys
for #512
2023-06-07 12:43:48 -07:00
Ryan Barrett 2941d79b64
move follow.fetch_webfinger to webfinger.py 2023-06-06 11:29:36 -07:00
Ryan Barrett ca64793fff
AP users: add User.name() and label_id(), ActivityPub.address computed property
for #512
2023-06-01 21:37:58 -07:00
Ryan Barrett cec093ea60
AP users: parameterize /remote-follow by protocol
for #512
2023-05-30 16:53:08 -07:00
Ryan Barrett 29f1a1d4ac
AP users: start parameterizing URLs, including UI pages and AP endpoints
user pages now have /[protocol]/ prefix, AP endpoints have /ap/ prefix. for #512
2023-05-30 16:38:58 -07:00
Ryan Barrett 8d4228b811
AP users: change web UI user page paths from /user/... to /[protocol]/...
for #512
2023-05-30 14:08:47 -07:00
Ryan Barrett c8b2103e13
rename Webmention class => Web, webmention.py => web.py 2023-05-26 17:40:29 -07:00
Ryan Barrett eaa4e5333a
start to make User subclasses for each protocol
#512
2023-05-26 16:07:36 -07:00
Ryan Barrett d2ab48b23e
switch circular imports to runtime imports; split out flask_app.py from app.py
runtime imports are just as bad, but...meh. eventually I'll untangle them for real. #486
2023-04-18 17:18:17 -07:00
Ryan Barrett 106bbe623b
tests optimization: reuse same RSA key across Users
speeds up tests from ~22s to ~6s (!) on my laptop. for #398
2023-03-10 15:13:45 -08:00
Ryan Barrett fd27dabe61
switch JSON properties to custom JSONProperty that works in web console UI
https://github.com/googleapis/python-ndb/issues/874#issuecomment-1442753255
2023-02-24 07:25:29 -06:00
Ryan Barrett 91a60c7e67
switch Object.as1 to be a ComputedProperty 2023-02-23 21:17:26 -06:00
Ryan Barrett 88db2afce3
follow/unfollow UI: store IndieAuth in session cookie
fixes #416
2023-02-17 16:12:25 -08:00
Ryan Barrett d5eac953d0
more error handling for signup UI flow when user's web site fetch fails
fixes #400
2023-02-08 20:28:30 -08:00
Ryan Barrett 4b37674624
always sign requests with current user's key, stop defaulting to snarfed.org
for #403
2023-02-06 19:23:25 -08:00
Ryan Barrett e42c11bab2
make follow UI respect User.use_instead
once more, with feeling for #403
2023-02-05 20:59:39 -08:00
Ryan Barrett d74c00f5b6
unfollow: handle Follower.last_follow with string id instead of object
fixes #402
2023-02-04 21:23:04 -08:00
Ryan Barrett f9891b6ef7
Activity => Object: add activity label, unify Objects for AP => wm
#286
2023-02-04 20:46:27 -08:00
Ryan Barrett 4d2fcdd76f
Activity => Object: fully populate labels, source_protocol webmention
#286
2023-02-04 20:46:27 -08:00
Ryan Barrett 23aff3b176
Activity => Object: update follow.py 2023-02-04 20:46:27 -08:00
Ryan Barrett 55ee0e468a
update follow tests for snarfed/oauth-dropins@52b00f602f 2023-02-04 20:46:10 -08:00
Ryan Barrett 82547c9557
override User.get_by_id() to handle use_instead
fixes #403
2023-02-04 19:53:30 -08:00