Wykres commitów

126 Commity (088ed350408bd75f36b430959d1ff37237c648cc)

Autor SHA1 Wiadomość Data
Marnanel Thurman 088ed35040 CreateActivitySerializer mostly working; to and cc are constants, which they shouldn't be.
Test now passes.
2020-10-29 00:52:34 +00:00
Marnanel Thurman 07d6597611 test_read_announce working; that class renamed Tests per policy 2020-10-29 00:49:28 +00:00
Marnanel Thurman e7c36ffb64 create() relies on the Follow object to send the "followed" signal, rather than doing it itself 2020-10-24 23:19:46 +01:00
Marnanel Thurman fe12ccbf22 auto_follow=False on test user to simplify debugging 2020-10-24 23:10:18 +01:00
Marnanel Thurman ba27b594a2 Deserialisation methods were split between sombrero_sendpub.fetch() and bowler_pub.create(). They're now all in create().
Tests updated.

test_announce filled in and made to pass. Closes issue #45.
2020-10-19 16:54:22 +01:00
Marnanel Thurman ee8c5fa285 If your test uses create_remote_person with auto_fetch=True, it gets ValueError if the fetch fails.
This is because the fetch shouldn't fail-- we *just* mocked something at that address. So if it fails, you set up your test case wrongly.
2020-10-19 16:46:36 +01:00
Marnanel Thurman 71f5186d7f corrected "log.warning" to "logger.warning" 2020-10-19 16:20:22 +01:00
Marnanel Thurman bb67a18112 Where an identifier of a remote object is called "url", rename it to "remote_url".
We were calling it "url" in some places and "remote_url" in others.
2020-10-19 16:17:58 +01:00
Marnanel Thurman d3c0663a96 LocalPerson gains "featured" attribute. Bowler gains FeaturedView.
Tests updated. Closes issue #41.
2020-10-11 15:36:58 +01:00
Marnanel Thurman 265f863746 test to demonstrate that featured collections are broken (see issue #41).
Test object in test_views renamed "Tests" per my own style guide.
2020-10-11 15:07:17 +01:00
Marnanel Thurman c21047f2a9 test fixed to expect the shared inbox to be called /sharedInbox and not /inbox.
It was broken by commit 13ff6ba6.
2020-10-09 03:13:59 +01:00
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 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 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 1ae4abdf37 docstring for create_remote_person() 2020-09-19 12:50:57 +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 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 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 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 af479642df Tests for previous commit (not checked in by error). 2020-08-27 15:42:18 +01:00
Marnanel Thurman 5ba53dfbb2 The MIME type of JPEGs serialised to ActivityPub was misspelled as "image/jpg" (instead of "image/jpeg"). Fixed.
Tests updated.
2020-08-27 15:35:06 +01:00
Marnanel Thurman b0aa91da76 ActivityPub representation for Persons has the publicKey field
being an object, not a string. This was a regression.

Tests updated. Thanks to vpzom for catching this.

Also, the same representation's "endpoints" object is now generated
on the fly. This means that changes to the TESTSERVER variable
during testing are correctly represented.
2020-08-27 15:25:54 +01:00
Marnanel Thurman bb2a5b48fb "sharedInbox" returns the shared inbox URL and not a user's outbox URL! 2020-08-25 15:21:48 +01:00
Marnanel Thurman a6e80e1de6 Person.lookup() removed because it duplicates the functionality of fetch().
There is one difference, which I think isn't important in the circumstances.
If lookup() is asked about a remote person that we don't already know about,
it either creates a blank record for them and returns it, or raises an error.
In these circumstances, fetch() will perform a lookup and populate the record
accordingly.
2020-08-23 18:10:50 +01:00
Marnanel Thurman 4d7d0c7754 rm bowler_pub/views/README.md because it was out of date and misleading 2020-08-23 17:17:05 +01:00
Marnanel Thurman ad34290cf2 If create() is asked to Create something, the type of the new object is case-insensitive. 2020-08-23 00:19:38 +01:00
Marnanel Thurman 33555806e8 The great types in trilby_api, Person and Status, now have
local_form() and remote_form() class methods. This is to
allow fetch() to check whether something is already cached
before fetching it.

LocalPerson also gains a status() method for symmetry with
RemotePerson; it always returns 200.

Tests updated.
2020-08-22 22:26:22 +01:00
Marnanel Thurman d835a9bd83 "Create" messages require the object being created to have a type we can actually use.
This regressed in commit a2a790f1. Before then, handlers could be defined for particular object types.
When we moved to general-case handlers for each Activity type, we should have added object type checks
to replace the checks implicit in the type-specific handlers.
2020-08-21 23:45:42 +01:00
Marnanel Thurman 623041ba49 fix debug messages 2020-08-21 23:41:54 +01:00