Wykres commitów

828 Commity (bowler-heavy)

Autor SHA1 Wiadomość Data
Marnanel Thurman c4a07a9e52 Home timeline can't have Nones in it 2020-02-28 01:15:02 +00:00
Marnanel Thurman 560eed7b40 /api/v1/statuses for all statuses renders into JSON correctly,
plus passing test.
2020-02-28 01:04:59 +00:00
Marnanel Thurman 9fa7031f5f Trilby's status numbers are now the numbers of the actual AcItem,
not the AcCreate which created it.

Suddenly, all the code is clearer.
2020-02-28 00:53:24 +00:00
Marnanel Thurman bb1210fd24 "Favourite" view generalised, and made a subclass of the generalised class.
Test generalised likewise.
2020-02-26 23:48:31 +00:00
Marnanel Thurman ab2dea89a6 Further to adding Favourite support to trilby_api: the test now passes.
The IDs of actor and object are set consistently.
The type field is set on the Like object(!)
2020-02-23 00:53:28 +00:00
Marnanel Thurman 576081f6a3 First sketch of Activities in trilby_api. Added "Favourite" view
which can create a Like. Tests supplied; they currently fail.

AcActivity gains an f_object field to support this.
2020-02-23 00:32:09 +00:00
Marnanel Thurman d61aad22e8 TrilbyUser will only create an associated AcPerson if one hasn't already been supplied. 2020-02-23 00:31:30 +00:00
Marnanel Thurman ee95ed2863 Two hacks to keep tootstream happy:
- /api/v1/instance is also at /api/v1/instance/
 - the version reported is always 1.0.0. This is because we're
   mimicking the Mastodon API, so we reply giving the corresponding
   Mastodon version. (Or, as in this case, we guess and see what works.)
2020-02-17 19:50:09 +00:00
Marnanel Thurman 7cab79775e trilby AccountsSearch stub 2020-02-10 21:45:47 +00:00
Marnanel Thurman 5ecf08cdcc stub for /api/v1/search 2020-02-10 00:28:56 +00:00
Marnanel Thurman 2bc69c1250 The "serial" field of bowler_pub's AcItem moves up to AcObject;
all objects, remote and local, now have serial numbers.

This is partly to make it easier for trilby_api to provide
decimal "id" numbers, and partly so that status URLs can contain
monotonically increasing decimal numbers. This last part
has not yet been implemented; status URLs still contain the
hex ID of the status.

It's possible that we can simplify this design a bit;
we should think about refactoring.

The regexp for local hex numbers is renamed to LOCAL_NUMBER_REGEXP
because it used to contain the word "SERIAL", which was misleading.

trilby_api now returns the "serial" field as "id"; see above.

Tests updated.
2020-02-04 01:38:54 +00:00
Marnanel Thurman 01a85e38a8 The "id" field in the Mastodon API is always a decimal string.
We convert it to a hex string for use internally, but some clients
(e.g. Tusky) expect a decimal string.

See:
https://socialhub.activitypub.rocks/t/verify-credentials-im-doing-something-wrong-here/440/3
2020-02-03 22:28:51 +00:00
Marnanel Thurman 4f57cc3b90 Statuses returned via the Mastodon API always have IDs which are
decimal integer strings.

This is to keep Tusky etc happy. See
https://socialhub.activitypub.rocks/t/verify-credentials-im-doing-something-wrong-here/440/3
2020-02-02 00:58:08 +00:00
Marnanel Thurman 25a1b40461 "acct" returns simply the account name for local accounts,
and preferredUsername@hostname for remote accounts.

This change was suggested at
https://socialhub.activitypub.rocks/t/verify-credentials-im-doing-something-wrong-here/440/2
2020-01-23 01:52:26 +00:00
Marnanel Thurman 72fd4499cb stub "following" and "followers" added to trilby 2019-12-30 15:14:34 +00:00
Marnanel Thurman f7f59d2ed9 Creating a Django user also creates an associated AcPerson 2019-12-25 23:52:35 +00:00
Marnanel Thurman 474075cd5c For the public timeline, we query each status to see whether it's public,
rather than attempting to do it via a database filter.

Database filters will fail because public-ness is based on
several possible considerations.

trilby_api.tests.create_local_status gains a "to" parameter.

Tests added.
2019-12-25 23:21:43 +00:00
Marnanel Thurman c014bd6408 added on_like handler to create a "favourited" notification, plus test 2019-12-19 21:02:20 +00:00
Marnanel Thurman fa6e49bf43 Mastodon's notifications give a dict for account and status, not just their ID 2019-12-19 18:51:17 +00:00
Marnanel Thurman b5f32bb87f Fixed trilby_api.tests.test_rest to accept the new (correct) "acct" value 2019-12-19 18:50:40 +00:00
Marnanel Thurman 12db4732cb AcActor handles display_name correctly for local users (regression fixed) 2019-12-19 18:49:51 +00:00
Marnanel Thurman 37054416d9 trilby's Notification gains attribute about_account_actor 2019-12-19 18:44:34 +00:00
Marnanel Thurman 985a23ce5c AcObject gains attributes: acct, hostname, preferredUsername, and display_name 2019-12-19 18:43:41 +00:00
Marnanel Thurman 5694851bcd In trilby_api.models
====================

Notification uses constants within the class
to represent notification types, as the docs recommend, rather than
using enum.Enum.

Notification.about_account is added. The existing "account" field
is renamed for_account for clarity.

Notification also gains a __str__() method.

on_follow modified to work properly with these changes.

Several migrations added. Note that trilby's 0006 migration is
deleted but there's a new 0006; you might have to wind back to
0005 to allow this migration to work. There are dependency
reasons for doing it like this.

In trilby_api.serializers
=========================

NotificationSerializer modified to return about_account.
It also gets immediately monkey-patched to return
notification_type as "type". Rather messy hack,
but StackExchange says this is the way to do it.

In trilby_api.views
===================

Notifications requires authentication(!) and returns
only the authenticated user's notifications.

In tests
========

test_notifications's test_follow fixed. It didn't work
before, despite the claim in commit 37095e; that was wrong
because the results weren't actually being checked.
2019-12-18 18:06:51 +00:00
Marnanel Thurman 0f2192edad bowler_pub.tests.create_remote_person() has a default publicKey field 2019-12-18 17:58:28 +00:00
Marnanel Thurman 37095e6f1d trilby integration with signals so on_follow notifications work.
Test for this passes; moving it to new test_notifications.py.
2019-12-18 16:30:56 +00:00
Marnanel Thurman 3f53925712 trilby_api.models.Notification added.
Serializer and test stub included.

Nothing actually creates Notifications yet, though.
2019-12-07 02:03:38 +00:00
Marnanel Thurman bf5a8bde07 "deleted" signal is sent when a Delete activity is successful.
Tests included.

Also, "alice" in test_signals has been renamed "arthur",
since all the test messages were from HHGTTG anyway.
2019-12-07 01:30:48 +00:00
Marnanel Thurman 81fb007eb0 Added test for the new "updated" signal.
Added test for the "Update" side_effect.
2019-12-01 20:53:44 +00:00
Marnanel Thurman aa7d5c9a68 create() can pass the send_signal flag through to the side_effect routines.
Because of this, the side_effect routines take **kwargs,
as does run_side_effects() in AcObject.

The side_effect routine for Update can update cached data for remote objects.
It doesn't attempt to modify the "id" or "type" fields on any object.

AcObject gains an items() method, by analogy with dicts etc.
It's just syntactic sugar around activity_form.
2019-12-01 20:52:01 +00:00
Marnanel Thurman 9bf422d834 bowler_pub can send "created" signal on creation.
"deleted" and "updated" signals defined but not yet used.

Tests added.
2019-11-28 19:00:09 +00:00
Marnanel Thurman 07647a39eb Version bump to 0.4.1 2019-11-20 19:11:21 +00:00
Marnanel Thurman 781750bdf0 Renamed entire project from "chapeau" to "kepi".
This is because of a name clash in PyPI.
2019-11-20 19:10:10 +00:00
Marnanel Thurman 00fa10b41c "kepi" module, which implements ActivityPub, renamed to "bowler_pub".
This is to prepare for the rename of the entire project to "kepi".
2019-11-20 19:05:40 +00:00
Marnanel Thurman 999ccf787e Version bump to 0.4.0 2019-11-20 18:42:17 +00:00
Marnanel Thurman 8c7e80afd6 AcActor.activity_form() no longer blanks the summary (bio) field.
Test included.

Also, rm an obsolete comment.
2019-11-17 18:10:29 +00:00
Marnanel Thurman ded1a1c45d AcActor.activity_form() includes "publicKey".
This was introduced in commit 047aec. AcActor's activity_form() expects to get
a field named "publicKey" from its parent method, and to rearrange that.
But renaming f_publicKey to publicKey meant that the parent method
assumed it wasn't public, and didn't put it into its result.

Test included.

Closes issue #35.
2019-11-17 18:00:18 +00:00
Marnanel Thurman d1d5a87719 If we receive a duplicate follow request, warn but don't raise an exception. 2019-11-16 18:13:30 +00:00
Marnanel Thurman d3e5e02e1b When a user has auto_follow, and we receive a Follow request,
we generate an Accept. This Accept was create()d with side_effects=False,
which prevented the Following from being created. Now fixed.
2019-11-16 18:09:00 +00:00
Marnanel Thurman 047aecf8f1 AcActor's f_publicKey renamed to publicKey.
"f_publicKey" would mean it can be set automatically. Because it's
typically a JSON object, it can't be represented with a simple type,
so it can't be set automatically; it must be represented in ThingField.

This didn't make a practical difference before, but since commit 6ce087
create() has honoured the "f_*" convention.
2019-11-16 17:39:54 +00:00
Marnanel Thurman c82a6def70 AcItem gains a "serial" field for the serial number (at the end of
the URL path, after the username). It gets set automatically.
2019-11-16 17:37:35 +00:00
Marnanel Thurman 6ce087579f create() fills in as many fields as it can when it creates an AcObject,
then sets the others by subscripting.

"As many fields as it can" means
  - the id field
  - any field whose name begins with "f_".

Previously, create() filled in as few fields as it could
(typically only the id, if supplied), then set the others by subscripting.

This change increases efficiency, but also allows the save() method
of AcObject and its subclasses to take account of the intial values of
the f_* fields.
2019-11-16 17:33:38 +00:00
Marnanel Thurman 622f147969 Many lookup properties moved out of TrilbyUser to AcActor.
Corresponding AcActor getitems removed.

Trilby's UserSerializer (and its descendants) serialize AcActor,
not TrilbyUser. Suddenly everything becomes simpler.

Tests updated.
2019-11-15 00:16:30 +00:00
Marnanel Thurman adaef590e3 AcItem gains an "actor" property, which returns the AcActor for f_attributedTo 2019-11-14 23:43:33 +00:00
Marnanel Thurman 6b14baafa2 trilby_api's HomeTimeline view now works. Tests added.
test_integration's main test renamed to TestIntegration.
2019-11-10 00:57:33 +00:00
Marnanel Thurman b1162df8bb Collection.members returns the actual objects in the collection, not the CollectionMember objects referring to them 2019-11-10 00:56:52 +00:00
Marnanel Thurman 2a43cfce48 The restriction on actors not being told about their own activities
is now only applied to incoming activities, as the spec requires.

For local activities, the actor is *always* told about their own activities.

Tests updated.
2019-11-10 00:56:39 +00:00
Marnanel Thurman 331a265fe4 Mastodon's emoji url is "custom_emojis", not "emojis" 2019-11-08 14:46:43 +00:00
Marnanel Thurman 44a6457639 remove use of CurrentUserDefault() which doesn't work the way I thought 2019-11-08 14:39:13 +00:00
Marnanel Thurman 7c73d926d3 Pass context containing request into StatusSerializer creation 2019-11-08 14:38:46 +00:00