backlink management
Goal
We need a mechanism that creates automatically backlinks, whenever a relation to a remote object is created.
Eg, If I add a user in the members of my group, my server should notify the server of the user so that it adds the group in the list of the user.
Proposed Spec
- All containers, resources and nested-fields should receive inboxes automatically
This should be provided as a view in the ViewSet, by default on a url
/model/inbox/
The Inbox contains logic to respond to different kinds of messages received by another server
- Detect when a remote entity has been attached to some data Currently you can POST remote entities, and they will be saved locally as an empty object with the remote id: https://git.startinblox.com/djangoldp-packages/djangoldp/blob/master/djangoldp/tests/tests_save.py#L287
LDPSerializer.create
& LDPSerializer.update
should be extended to send the backlink notification on any nested fields being added with remote origins: https://git.startinblox.com/djangoldp-packages/djangoldp/blob/master/djangoldp/serializers.py#L517
- Discover the target inbox According to the LDNotifications spec, this should be done "through a relation in the HTTP Link header or body of the resource"
A GET or OPTIONS request can be sent to the server to retrieve this information. The ViewSet on the target resource will be extended in (0.) to include inbox information in the response
- React to the notification on target server Create the backlink as a "ghost" object (i.e. containing no fields, just the URLid of the host server)
For example if I post a remote user to a circle, then the remote server will add a reference to this circle, and then add it to the user's list of circles
- I'm not sure here if it will be difficult to discover the references which should be updated in an automatic way (i.e.
circles/members/
anduser/circles/
). Possibly it can be done with the FieldInfo on the resource: https://github.com/encode/django-rest-framework/blob/908f91d8ef13649b6d658981e28ff52296b19f9f/rest_framework/utils/model_meta.py#L6 - Authentication that I want to add the circle.. if the sending server & resource are both in my
LDPSource
s?
- Unit tests that the ghost object is returned in responses at both ends (e.g.
user.circles.all()
andcircle.members.all()