Commit graph

128 commits

Author SHA1 Message Date
Wesley Aptekar-Cassels e9f26b7d50
Merge pull request #2800 from WesleyAC/fix-activitypub-request-accept-header
Fix Accept header for requesting ActivityPub objects
2023-04-08 11:02:27 -04:00
Wesley Aptekar-Cassels 912d0a0149 Fix Accept header for requesting ActivityPub objects
This is the header described in the ActivityPub spec, which should fix
some federation problems with GoToSocial and potentially other picky
services.

Related: #2794, superseriousbusiness/gotosocial#1676
2023-04-07 05:57:13 -04:00
Wesley Aptekar-Cassels b574a12fff Pass allow_external_connections through ignore_activity
Previously, ignore_activity could unexpectedly make a outgoing HTTP
connection, leading to unwanted latency, particularly when called via
ActivityObject.to_model, which had the allow_external_connections
parameter already.

Related: #2717
2023-04-06 23:37:49 -04:00
Mouse Reeve 12af5992a3
Merge pull request #2524 from chdorner/feature/tag-support
Initial hashtag support
2023-03-12 16:37:39 -07:00
Wesley Aptekar-Cassels 9cbff312a5 Ignore Celery task results
Since we don't use the results of our Celery tasks (all of them return
None implicitly), it's prudent to set the ignore_result flag, for a
potential performance improvement. See the Celery docs for details [1].

We could do this with the global CELERY_IGNORE_RESULT setting, but it
offers more flexibility if we want to use task results in the future to
set it on a per-task basis.

[1]: https://docs.celeryq.dev/en/stable/userguide/tasks.html#ignore-results-you-don-t-want
2023-03-08 02:12:13 -05:00
Christof Dorner 11640f986e Import hashtags from activitypub statuses 2023-03-07 12:59:31 +01:00
Christof Dorner c68304a99b Parse hashtags and store them in CreateStatus view 2023-03-07 12:55:36 +01:00
Mouse Reeve 779d2b0694 Attempt to complete inbox requests synchronously
When an inbox activity comes in from another fediverse instance, the
behavior prior to this commit was always to immediately give a 200
response to the external server and then create a celery activity
(usually in the MEDIUM_PRIORITY queue) to complete it.

Instead, this would receive a request and try to complete it without
making any http requests (which would make the request take too long to
process). If an external request is required to complete the activity, a
task is created and added to the queue.

Ideally, this will cause some tasks to happen very promptly, and reduce
the load on celery, which would help queued tasks happen more quickly as
well.

One downside is that this will make completing http requests from
external servers slowing (since it's doing a bunch of thinking before
responding).
2023-02-20 11:05:18 -08:00
Hugh Rundle f0e1767bc9 black code 2023-01-22 16:10:30 +11:00
Hugh Rundle 803bba71a6 fix error handling
- when using raise_for_status we need to catch an HTTPError, not a ConnectionError
- simplify instance actor - use internal email address since it will never be used anyway, and make default username less likely to already be in use.
2023-01-22 15:59:19 +11:00
Hugh Rundle 317fa5cdfd black 2023-01-20 20:05:14 +11:00
Hugh Rundle e8452011f7 handle get_data exceptions better
Makes exception handling more precise, only raising status for 401s.

Also fixes a string pylint was complaining about.
2023-01-20 19:55:38 +11:00
Hugh Rundle f8c9df4aff pylint fixes 2023-01-20 18:20:18 +11:00
Hugh Rundle 4108238716 resolve SECURE_FETCH bugs
ERROR HANDLING FIXES

- use raise_for_status() to pass through response code
- handle exceptions where no response object is passed through

INSTANCE ACTOR

- models.User.objects.create_user function cannot take an ID
- allow instance admins to determine username and email for instance actor in settings.py
2023-01-20 16:32:17 +11:00
Hugh Rundle d66e2fe861 merge in latest changes 2023-01-18 14:12:01 +11:00
Fedor Indutny cdc833657f Fix serialization of JSON-LD subarrays
Properties like "tag" could be lists containing multiple subclasses of
ActivityObject. Make sure to serialize them recursively instead of
outputting them as they are, because otherwise we could get a bunch of
nulls in the resulting JSON and that wouldn't necessarily be a valid
JSON-LD object.

Fix: #2451
2022-12-04 18:12:39 -08:00
Mouse Reeve b37a4322de Change log level to info for connector exceptions
These errors in resolve_remote_id aren't really errors, they're
routine problems that we can expect from dealing with the outside world,
like a connection timeout, a server being down, a server being blocked,
et cetera. It's cluttering up the logs and causing unnecessary worry.
2022-11-17 12:35:19 -08:00
André Jaenisch 530d7de309
Use variable instead of string
Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
2022-11-13 16:59:05 +01:00
Mouse Reeve 7eb2a82e5f
Merge branch 'main' into misc/add_signatures_to_requests_for_masto_compat 2022-07-26 15:46:18 -07:00
Mouse Reeve 77a7dfa924
Merge pull request #2133 from bookwyrm-social/activitypub-connection-erorr
Don't throw an error when unable to connect to remote data
2022-05-26 10:12:18 -07:00
Mouse Reeve 88b2cffcf2
Merge pull request #2035 from bookwyrm-social/stopped-shelf
Stopped shelf
2022-05-26 10:11:32 -07:00
Mouse Reeve 3e54a5f4a3 Python formatting 2022-05-26 09:00:45 -07:00
Mouse Reeve 0bfe1e9dfc Don't throw an error when unable to connect to remote data 2022-05-25 13:24:11 -07:00
Mouse Reeve b2775c5160 Check unsupported types before attempting to serialize 2022-05-16 10:21:54 -07:00
Mouse Reeve fd43b56d31 Fixes celery error encountering Article type activities 2022-05-16 10:17:21 -07:00
Mouse Reeve 819458e82a Improves error reporting on activitypub parser 2022-03-16 13:53:54 -07:00
Mouse Reeve d2dab0f2db
Merge branch 'main' into misc/add_signatures_to_requests_for_masto_compat 2022-03-01 10:20:39 -08:00
Mouse Reeve c06817e9ff Python formatting 2022-02-09 12:23:01 -05:00
Mouse Reeve 6323b0e700 Use correct model type for federated links 2022-02-09 12:20:11 -05:00
Mouse Reeve 8cc4427e60
Merge branch 'main' into misc/add_signatures_to_requests_for_masto_compat 2022-01-13 11:37:54 -08:00
Mouse Reeve d1183fd003 Python formatting 2022-01-12 17:11:24 -08:00
Mouse Reeve 5fcdc284ce Removes duplicate atomic block 2022-01-12 16:41:23 -08:00
Mouse Reeve 6c78a7b6ef Add user attribution to links and domains 2022-01-10 13:20:31 -08:00
Mouse Reeve 4dfe9fd714 Support links with no name 2022-01-10 11:21:43 -08:00
Mouse Reeve 32e3fdb438 Adds admin view 2022-01-10 10:12:28 -08:00
Mouse Reeve 70fe7e17af Removes name ap field 2022-01-09 14:25:22 -08:00
Renato "Lond" Cerqueira e2ee3d27a7 WIP 2022-01-05 15:47:05 +01:00
Renato "Lond" Cerqueira 097d86454a Add signatures to requests to mastodon to support authorized fetch mode
When mastodon is in authorized fetch mode any request has to be signed
or it fails with 401. This adds the needed signature to the requests
made to discover the actor when receiving something from mastodon (such
as a follow request)
2022-01-05 15:46:42 +01:00
Mouse Reeve 5c99f142f9 Serialize links for books 2021-12-15 17:12:53 -08:00
Mouse Reeve 86b294afd7 Re-structures link models 2021-12-15 16:23:21 -08:00
Mouse Reeve 377a4e1ef1 Updating string format syntax part 1 2021-09-17 21:39:18 -07:00
Mouse Reeve de3f18655c Set priorities on tasks 2021-09-07 16:33:43 -07:00
Mouse Reeve 53d9ff87d9 Look up followers url to determine post privacy 2021-08-28 10:40:52 -07:00
Mouse Reeve bbe5ad7ce1 Suppresses pylint warning 2021-08-17 10:49:11 -07:00
Mouse Reeve ad0fff7030 Prevent overwriting data on import form outside data source 2021-08-17 10:08:07 -07:00
Mouse Reeve 21a954c7df Always use underscores in html ids
Plus some other shifting around
2021-08-08 19:44:12 -07:00
Mouse Reeve a84a744e8d Track changed fields in activity to model code 2021-08-03 08:48:15 -07:00
Mouse Reeve 4479864008 Updates code for linter 2021-06-18 14:12:56 -07:00
Mouse Reeve 3ade2d3bb1 New version of black, new whitespace 2021-04-26 09:15:42 -07:00
Mouse Reeve caa261f4bf Gracefully handle expect, unsupported activities 2021-04-16 15:12:38 -07:00