Wykres commitów

1259 Commity (main)

Autor SHA1 Wiadomość Data
Marnanel Thurman c9ad177220 Added top-level exception handler to InboxView, since it seems to be experiencing difficulties.
Really this needs to be a more general solution.
2020-09-30 16:20:22 +01:00
Marnanel Thurman ceed10b278 DEBUG=False by default! 2020-09-30 16:14:48 +01:00
Marnanel Thurman b5a7f7114d Attempts to fetch(None) get None.
It sometimes happens in the wild that someone submits "inReplyTo: null" or similar.
2020-09-30 16:13:02 +01:00
Marnanel Thurman 3d38c6618a Replaced the "requested" flag in Follow with an "offer" field which holds the ID of the follow request. 2020-09-30 15:44:16 +01:00
Marnanel Thurman 9d8f4613d4 When trilby_api hears about a follow request, and the person being
followed has "auto_follow" turned on, the request is automatically
granted. If the follower is remote, they automatically get sent an
Accept activity. This fixes a regression.

As part of this, bowler_pub.create() now sends the ID of the Follow
activity through the signal.

Also, trilby_api.receivers now uses sensible renames for the
"sender" parameters-- they're really the activities which caused
the signal.
2020-09-28 17:08:15 +01:00
Marnanel Thurman 3a1a5f6db2 Remote users following local users causes the "followed" signal 2020-09-28 16:30:58 +01:00
Marnanel Thurman dbc5e47b4b Messages posted to user inboxes, and to the shared inbox, will be acted upon.
Closes issue #37.
2020-09-21 18:10:34 +01:00
Marnanel Thurman 4982c4daed Two tests in test_create were attempting to resolve "somewhere.example.com"
(and failing, obviously). This should have been mocked but wasn't.
This need some deeper investigation so I've @skip()ped them for now.
(One of the tests was previously @expected_failure.)
2020-09-21 18:09:10 +01:00
Marnanel Thurman 0eb479129f extra debug logging 2020-09-21 18:08:48 +01:00
Marnanel Thurman 9afc7dd220 If you pass a bytestring to validate(), and it doesn't decode cleanly, log this and exit gracefully.
There's still a remaining issue: we always decode the bytestring as UTF-8, but it might not be. Marked with XXX.

Hence also: log.info() the incoming message before attempting to decode the bytestring.

Also: don't bother logging when we've launched the validation task, since that always succeeds.
2020-09-21 17:55:46 +01:00
Marnanel Thurman 0679cb12ae log_one_message allows the "body" parameter to be a bytestring as well as a dict.
This is because incoming messages are no longer parsed straight away (see commit 83b69f2f).
2020-09-21 17:50:19 +01:00
Marnanel Thurman 293191a1f6 The bowler_pub functions which create test messages require extra fields to be supplied as a "fields" parameter.
Previously we allowed callers to specify them as arguments, if the argument name was preceded by "f_".
This caused ambiguities and was too much faff to be useful.

Tests updated accordingly.

Also, one test message copied from the ActivityPub spec was slightly in breach of actual usage conventions. Fixed.
2020-09-21 17:48:51 +01:00
Marnanel Thurman 83b69f2fcb ActivityParser doesn't parse the JSON of incoming messages.
This is because when we validate the message, a little further
down the line, we need access to the exact content of the message.
Parsing it here would destroy the exact content, because Django
doesn't let you read request bodies twice.
2020-09-21 17:43:57 +01:00
Marnanel Thurman f95163dc04 Drop incoming messages with no type 2020-09-21 17:43:32 +01:00
Marnanel Thurman 2043ca8eaf When we create a Status from a Create message, catch exceptions and treat as failure. 2020-09-21 17:08:20 +01:00
Marnanel Thurman 482f3132e0 rm unused field "is_local_user" in IncomingMessage 2020-09-20 23:53:54 +01:00
Marnanel Thurman c4c5555c8b Modernised the "send to inbox" tests which were taken from bowler_heavy.
Previously they were all marked @skip. They are no longer skipped, but they don't pass.

Clearly there's work to be done there. More work will probably also be needed in modernising the tests.
2020-09-19 20:32:27 +01:00
Marnanel Thurman 82d8c55701 Added a django-rest-framework parser so we accept uploads of type
"application/activity+json".
2020-09-19 20:29:12 +01:00
Marnanel Thurman 6023aa9c36 Inbox stub status should be 403, not 410!! 2020-09-19 18:33:24 +01:00
Marnanel Thurman 513c2d52e5 logger.warn is now logger.warning (pylint W1505) 2020-09-19 16:25:31 +01:00
Marnanel Thurman 1ce2d41e1e Updated all copyright dates to 2020 2020-09-19 16:18:32 +01:00
Marnanel Thurman 48fbb745de removed trailing whitespace throughout (pylint C0303) 2020-09-19 15:58:35 +01:00
Marnanel Thurman ebe785bda4 rm trailing newlines (pylint C0304) 2020-09-19 15:16:47 +01:00
Marnanel Thurman f4889f4def LocalPerson: inbox -> inbox_url, and inbox_collection -> inbox.
This fixes a regression.
2020-09-19 15:07:57 +01:00
Marnanel Thurman 4b513fb817 Several view fixes in bowler:
CollectionView.get() correctly passes username and listname through to activity_get().
This fixes a regression.

CollectionView.get() dereferences the result of activity_get() if it's an ActivityResponse.
This should have been part of commit d02042f2 but I missed it.
This fixes a regression.

CollectionView.get() uses len() to get the length of the result of activity_get(), and
not the result's count() method. This allows the result to be a list as well as a queryset.

CollectionView.activity_get()'s logging is slightly tidier.
2020-09-19 15:00:48 +01:00
Marnanel Thurman 197362b2c3 ActivityResponse's constructor actually stores its parameter.
I don't know how it even could have worked before.
2020-09-19 15:00:00 +01:00
Marnanel Thurman 0a9d266305 test_send_to_followers_of_remote_user() implemented and passing. 2020-09-19 14:42:57 +01:00
Marnanel Thurman c22f8d7c0e If fetch() rejects a message because the JSON was malformed, show the JSON parsing error in the log. 2020-09-19 14:42:31 +01:00
Marnanel Thurman 193faf061b Sombrero's test_delivery gains test_send_to_remote_user().
Thanks to Patrick Gosling for pointing out that lambdas in a loop need their own copies of a closure variable!
https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result
2020-09-19 12:52:00 +01:00
Marnanel Thurman 1f57997802 Several small fixes related to code moved out of a previous version
which hadn't yet been tested.
2020-09-19 12:51:25 +01:00
Marnanel Thurman 1ae4abdf37 docstring for create_remote_person() 2020-09-19 12:50:57 +01:00
Marnanel Thurman c1368cd128 sombrero's test_delivery has assertions in. (The previous stub version didn't.)
The tests for remote delivery are still unimplemented. Soon.
2020-09-16 23:18:25 +01:00
Marnanel Thurman d02042f247 bowler's Collection views refactored. It feels a bit like being the redactor of the book of Genesis.
The refactoring is more complicated than it sounds. The file activitypub.py
was created by merging two sets of views from the old bowler_heavy
branch. This resulted in two classes called InboxView, and of course
the second one in the file won out. I have merged them and fixed
the errors therein.

As part of this, I have discovered that d-r-f adds the requirement
that view methods return HttpResponse objects. Therefore we've had
to add a new class, ActivityResponse, whose only purpose is to
get around this requirement.

fetch() has been updated as appropriate.
2020-09-16 23:14:38 +01:00
Marnanel Thurman c586eecfcb The *_url methods of LocalPerson should always have been properties
(as they are for RemotePerson).
2020-09-16 20:32:26 +01:00
Marnanel Thurman cf94c4ba0a Test utilities involving local users have moved to trilby_api.
This is a bit complicated. We used to have two functions called
create_local_person(): one of them was in bowler_pub and the other
was in trilby_api. The bowler_pub one worked better because it
defaulted to using test keys rather than expecting the system
to make new ones, which is slow and wasteful.

Therefore, we have moved the c_l_p() from bowler into trilby,
and thrown the trilby one out.

While we're at it, we have also moved create_local_status and
create_local_like from bowler into trilby, and deleted trilby's
create_local_note.

This makes everything faster and easier.
2020-09-16 01:10:23 +01:00
Marnanel Thurman 5539aec729 Sombrero uses "inbox_url" rather than "inbox" on Trilby's Persons.
This should have been in commit 66373041, but it wasn't.
2020-09-16 01:09:02 +01:00
Marnanel Thurman 66373041e7 Trilby keeps track of all the URLs given for a RemotePerson. 2020-09-15 17:59:47 +01:00
Marnanel Thurman cad7621bd3 fix broken JSON in test constant 2020-09-15 17:59:27 +01:00
Marnanel Thurman a02a7a302c extra debug statement 2020-09-15 17:59:07 +01:00
Marnanel Thurman 3173249da1 Initialise some variables that weren't 2020-09-15 17:41:31 +01:00
Marnanel Thurman 08ae86db81 bowler's tests.remote_user has sensible values for featured, inbox, outbox, following, and followers 2020-09-14 01:41:40 +01:00
Marnanel Thurman c2bfe56e6e test_person's check of the "followers" property now checks remote followers of local accounts, and vice versa.
One passes, the other doesn't.
2020-09-14 01:30:13 +01:00
Marnanel Thurman c4cf668cc2 Partial checkin: deliver() now iterates over a given user's followers. This is insufficiently tested as yet.
deliver()'s target_people param now has a default of [], for parallelism with target_followers_of.
2020-09-14 01:15:27 +01:00
Marnanel Thurman e3520eee53 Partial checkin. The "followers" property on RemotePersons and LocalPersons is now handled separately.
On a LocalPerson, our own models are the authoritative source for their followers.
On a RemotePerson, we have to grab the list from the remote server.

I've made some tests for the LocalPerson part, but the RemotePerson part
still needs testing. This has involved creating a test_person module
in trilby, because test_account is for integration tests.
2020-09-14 01:06:38 +01:00
Marnanel Thurman 4530a517ca Intermediate checkin: major overhaul of deliver() to meet the requirements of issue #40.
Tests for local delivery added. These tests don't yet check the results. When they do, they will fail because of
issue #37.

No tests for remote delivery yet. They're coming soon.
2020-09-10 23:25:31 +01:00
Marnanel Thurman e09abfa356 The "inbox" collection property of LocalPerson is renamed to "inbox_collection".
This is for consistency with "inbox" for RemotePerson, which is merely the URL.

At some point it will need to be "get_inbox_collection", but that will
make it visible via ActivityPub and we need to make sure permissions are checked.
2020-09-10 23:23:05 +01:00
Marnanel Thurman f5e040d746 Sombrero's fetch() can now retrieve Collections and OrderedCollections.
Tests updated.
2020-09-09 23:55:55 +01:00
Marnanel Thurman 26a56611a2 log_one_message, a start at a common logging system for messages.
Submitted messages aren't currently logged because the whole
message submission system is currently broken.
2020-09-03 15:23:50 +01:00
Marnanel Thurman f0c3d08e35 Update name of Follow class used in view (used to be Following)
Also addded debug logging for CollectionView
2020-08-28 22:12:44 +01:00
Marnanel Thurman faf663be6f get_outbox_collection returns all the user's posts (for now). 2020-08-28 22:12:22 +01:00