Commit graph

45 commits

Author SHA1 Message Date
Wesley Aptekar-Cassels 3e78e398c0 Switch from priority queues to function-based queues
Fixes: #2907
2023-07-20 12:25:30 -04:00
Mouse Reeve a4ccd45537
Merge pull request #2812 from hughrun/gts
Fix federation with GoToSocial and inconsistent KeyId in headers
2023-05-29 19:54:00 -07:00
Hugh Rundle a0b7112c9c
Merge branch 'main' into gts 2023-04-14 18:24:02 +10:00
Hugh Rundle 56a062d01f pylint fixes 2023-04-13 20:21:35 +10:00
Hugh Rundle a6676718cb formatting 2023-04-13 13:27:51 +10:00
Hugh Rundle 03f21b0f35 Use correct keyId with legacy fallback
Bookwyrm keyIds are at `userpath/#main-key`, however when signing AP objects we have claimed in the headers that the keyId is at `userpath#main-key`.
This is incorrect, and makes GoToSocial's strict checking break.
Simply updating the signatures to use the correct KeyId breaks legacy Bookwyrm's signature checks, becuase it assumes that the keyId path is the same as the user path plus a fragment.
This commit allows for either option, by sending the request a second time with the incorrect keyId if sending with the correct one causes an error.
2023-04-11 15:45:06 +10:00
Hugh Rundle 49758f2383 formatting fixes 2023-04-10 17:50:25 +10:00
Hugh Rundle 632e3844b9 Don't assume user id is key id minus fragment
Fixes #2801
Related to #2794

It is legitimate to use any url for the user's key id. We have been assuming this id is the user id plus a fragment (#key-id) but this is not always the case, notably in the case of GoToSocial it is at /key-id. This commit instead checks the remote user's information to see if the key id listed matches the key id of the message allegedly received from them.

Whilst troubleshooting this it also became apparent that there is a mismatch between Bookwyrm users' keyId and the KeyId we claim to be using in signed requests (there is a forward slash missing). Since everything after the slash is a fragment, this usually slips through but we should be consistent so I updated that.
2023-04-10 17:32:49 +10:00
Wesley Aptekar-Cassels 1048638e30 Stop ignoring task results
This is essentially a revert of 9cbff312a. The commit was at the advice
of the Celery docs for optimization, but I've since decided that the
downsides in terms of making things harder to debug (it makes Flower
nearly useless, for instance) are bigger than the upsides in performance
gain (which seem extremely small in practice, given how long our tasks
take, and the number of tasks we have).
2023-04-07 21:51:44 -04:00
Josh Soref ba7f0fce71 spelling: whenever
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-04 20:02:54 -04: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
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
Mouse Reeve b89cab1ee5 Fixes args passed to inbox activity task 2023-01-25 07:39:43 -08:00
Mouse Reeve 858bf70d62 Make follow activities a high priority
This should go a long way towards fixing the problems with follows not
going through to remote servers. All it does is move relationship
related activities from the medium priority queue, which gets
backlogged easily, to the high priority queue, which is less backlogged.

The risk here is that the high priority queue could end up getting
backlogged, so this isn't the last word on fixing this, but I think the
volume of activities that this will add to it will be manageable.
2023-01-24 08:46:29 -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
Joel Bradshaw 27a0b92de0 Fix include order 2022-01-17 16:12:16 -08:00
Joel Bradshaw 13a2c58b98 Use parameter-based formatting for debug 2022-01-17 15:14:01 -08:00
Joel Bradshaw 5cf1d8a30a Make it black 2022-01-09 23:53:23 -08:00
Joel Bradshaw 83851c2933 Add bookwyrm-specific logging 2022-01-09 23:49:14 -08:00
Mouse Reeve c874a762dd Updates inbox view 2021-09-27 17:27:17 -07:00
Mouse Reeve acfb1bb376 Updating string format synatx part 2 2021-09-18 11:32:00 -07:00
Mouse Reeve de3f18655c Set priorities on tasks 2021-09-07 16:33:43 -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 02e6602a0b Reject statuses from deactivated remote users 2021-04-17 17:55:22 -07:00
Mouse Reeve 00c6b7e6e0 Fixes regex group 2021-04-13 18:26:54 -07:00
Mouse Reeve e8d1c04712 Fixes logic error in checking sender 2021-04-13 18:04:54 -07:00
Mouse Reeve 77caf1a8fa Merge branch 'main' into domain-block 2021-04-11 10:02:11 -07:00
Mouse Reeve 1903812b1d Class method for checking if urls are blocked 2021-04-10 11:44:29 -07:00
Mouse Reeve 6617cede37 Loudly throw errors in inbox task 2021-04-08 14:15:58 -07:00
Mouse Reeve ddba61f138 Block all/unblock all users on server block 2021-04-07 16:50:12 -07:00
Mouse Reeve a4b892dfad Fixes domain block tests 2021-04-05 16:47:48 -07:00
Mouse Reeve 34b790a086 Adds tests for blocked server checks 2021-04-05 15:54:33 -07:00
Mouse Reeve 1901f7e6cb Check if incoming domains are blocked 2021-04-05 15:16:41 -07:00
Mouse Reeve 70296e760b Runs black 2021-03-08 08:49:10 -08:00
Mouse Reeve 09b77e567f Check for invalid json before verifying signature 2021-03-07 09:44:42 -08:00
Mouse Reeve 91908eb1b6 Smarter way of inferring serializers (which are explicitly present) 2021-02-16 18:59:50 -08:00
Mouse Reeve a3b7063e4b makes inbox csrf exempt 2021-02-16 18:07:57 -08:00
Mouse Reeve d81bfb6573 Fixes unfollow 2021-02-16 16:35:28 -08:00
Mouse Reeve b57a86d4e2 Fixes approving follow requests automatically 2021-02-16 12:58:29 -08:00
Mouse Reeve 606d89d3bd Fixes boost, recursive to_model calls 2021-02-15 21:20:00 -08:00
Mouse Reeve 12a3aa9667 incoming Create flow with tests 2021-02-15 19:41:22 -08:00
Mouse Reeve 81e2021f92 Move handlers to activitypub classes 2021-02-15 18:47:08 -08:00
Mouse Reeve e810c2bee0 Recursively parse activities 2021-02-15 17:23:17 -08:00
Mouse Reeve fd19b55961 Basic checks for inbox 2021-02-15 16:27:25 -08:00