Wykres commitów

1083 Commity (0a9d26630586d29ebb8106480e5fdbbe4f315b7e)

Autor SHA1 Wiadomość Data
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
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 7368f2c372 serializers.py header 2020-08-25 15:50:25 +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 0ab9fecea4 suppress_thread_exceptions doesn't fail under Python 3.6.
It uses threading.excepthook, which doesn't exist in pre-3.8 Python. But there's no need to break all the tests under 3.6.

suppress_thread_exceptions was introduced in commit 001698cd.
2020-08-24 19:16:03 +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 f4d05bba40 Cleaning up header blocks, and making sure we use getLogger instead of creating a new one in each module 2020-08-23 17:40:54 +01:00
Marnanel Thurman 68a1c3c8ac Add tophat_ui, which currently gives us a simple root page and no more. 2020-08-23 17:32:42 +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 e1cb0208db A user's home timeline contains *all* posts of theirs, not just public and private ones
All trilby tests now pass
2020-08-23 17:13:01 +01:00
Marnanel Thurman 8d0eea8e75 some extra logging in views and models of trilby 2020-08-23 17:09:42 +01:00
Marnanel Thurman b42887616e Fix some of the headers in trilby.
Standard comment block at the start, and getting the logger in the same way.
2020-08-23 16:54:43 +01:00
Marnanel Thurman a4fa15e825 The Mastodon response to in_reply_to_account_id defaults to None.
This fixes a test failure.
2020-08-23 16:40:49 +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 f0d9a7203e create(), when asked to look up something atstyle, checks that it's a Person.
Previously this always failed because 1) "isinstance" was typoed as "isintance" and 2) "issubclass" was what was needed anyway.

Test now passes.
2020-08-23 00:18:18 +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
Marnanel Thurman a2a790f18f fetch() handlers simplified; on_announce now works
fetch() used to allow handlers to specialise for Activity and object type,
like on_announce_note. But we don't always know the type of the
"object" field when we receive it, because we might only have its
address. Therefore, handlers can now only be named by the Activity.

on_announce now passes the simple tests.
2020-08-20 18:01:26 +01:00
Marnanel Thurman ecbba37661 bowler's StatusView now has an activity_get method. 2020-08-20 18:00:35 +01:00
Marnanel Thurman ccdc414ad8 Undoing the AcObject changes introduced in e9d780d2.
The changes would require multiple inheritance, which
PolymorphicModel doesn't support.
2020-08-20 16:36:40 +01:00
Marnanel Thurman 39154b1450 bowler's views rejigged, and obsolete code removed. Views tests now pass. 2020-08-15 19:16:36 +01:00
Marnanel Thurman e9d780d2a3 trilby's Status and Person classes now descend from a common ancestor,
AcObject. This allows bowler to return objects it finds without having
to require a particular type.
2020-08-15 18:51:59 +01:00
Marnanel Thurman 4bf78f6c37 updating tests to use fetch() instead of fetch_user() 2020-08-06 23:07:45 +01:00
Marnanel Thurman 1278fca221 test_expected_localtype() was reversed in sense; fixed 2020-08-06 23:00:57 +01:00