Commit 68c00c31 authored by swentel's avatar swentel

Issue #3175474: like/announce

parent 340e41a6
......@@ -40,7 +40,7 @@ Use composer require drupal/activitypub to get all dependencies:
3. At this point, when a user has enabled activitypub at user
/x/activitypub/settings, they should be discoverable. Try searching for
@handle@domain on Mastodon. If you follow this user, an entry will arrive
in the inbox and an Accept outbox entry will be created automatically
in the inbox and an Accept outbox entry will be created automatically.
4. Configure global settings at admin/config/services/activitypub to
select how to process those outbox activities. Then either run cron,
configure a crontab for the drush command or manually call it. The
......@@ -49,7 +49,7 @@ outbox activities will be send then.
of all ActivityPub Type configuration entities. Two are enabled (and locked)
when enabling this module, which are the 'Accept' and 'Delete' types.
6. Create your own configuration
- Select 'Type plugin', only dynamic types are available
- Select 'Type plugin', only dynamic types is currently available
- Select the content type which you want to map
- Select the activity (See '1' and '2' underneath)
- Select the object (use Note if you do not want to populate a title)
......@@ -57,20 +57,23 @@ when enabling this module, which are the 'Accept' and 'Delete' types.
7. When saved, go to the content type you selected. You can now select the
entity which will process this node in the 'ActivityPub outbox' fieldset.
**important**
**Important**
1. The 'Send to' fieldset must currently have a value and point to a remote
user. Sending a post to multiple followers is in development and will arrive
soon.
2. Make sure a 'Reply' URL points to the canonical URL. For example,
do not use the URL in your browser for a Mastodon status
- Will work: https://mastodon.social/@swentel/104960564425633436
- Will not work: https://mastodon.social/web/statuses/104960564425633436
2. Make sure a Reply URL, Like object points to the id of the post You can get
this id from the application/activity+json representation of a post. Examples:
- Mastodon reply/like
- Will work: https://mastodon.social/@swentel/104960564425633436
- Will not work: https://mastodon.social/web/statuses/104960564425633436
- Pleroma like 'object' needs to be the id of an activity, not the browser
URL, but works fine for the inReplyTo property.
Footnotes:
1. Use Create when you want to send regular posts (e.g note, article or reply)
2. 'Announce' usually stands for the 'Boost'/'Retweet' response
2. 'Announce' usually stands for the Boost/Retweet/Repeat response
## Plugins
......
......@@ -34,9 +34,14 @@ class NodeController extends BaseController {
if ($actor && $activity) {
$build = $activity->buildActivity();
$object = $build['object'];
$object['@context'] = ActivityPubOutboxClientInterface::STREAMS_CONTEXT;
$response = new JsonResponse($object, 200);
if (is_array($build['object'])) {
$output = $build['object'];
}
else {
$output = $build;
}
$output['@context'] = ActivityPubOutboxClientInterface::STREAMS_CONTEXT;
$response = new JsonResponse($output, 200);
$response->headers->set('Content-Type', 'application/activity+json');
return $response;
}
......
......@@ -51,7 +51,7 @@ class DynamicTypes extends TypePluginBase {
'published' => 'Date',
'name' => 'Title',
'content' => 'Content',
//'object',
'object' => 'Like/Announce/Follow target',
'inReplyTo' => 'Reply link',
'attachment' => 'Image attachment',
];
......@@ -126,13 +126,26 @@ class DynamicTypes extends TypePluginBase {
}
$object['to'] = $to;
$activity = [
'type' => $this->getConfiguration()['activity'],
'id' => $this->renderUrl($activity),
'actor' => $activity->getActor(),
'to' => $to,
'object' => $object
];
// Create.
if ($this->getConfiguration()['activity'] == 'Create') {
$activity = [
'type' => $this->getConfiguration()['activity'],
'id' => $this->renderUrl($activity),
'actor' => $activity->getActor(),
'to' => $to,
'object' => $object
];
}
else {
$activity = [
'type' => $this->getConfiguration()['activity'],
'id' => $this->renderUrl($activity),
'actor' => $activity->getActor(),
'to' => $to,
'object' => $object['object']
];
}
return $activity;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment