fixed inbox problems with pleroma

This commit is contained in:
Matthias Pfefferle 2019-03-14 23:10:11 +01:00
parent fc0c162ac6
commit 8d91b213e7
7 changed files with 64 additions and 29 deletions

View file

@ -4,7 +4,7 @@
**Tags:** OStatus, fediverse, activitypub, activitystream **Tags:** OStatus, fediverse, activitypub, activitystream
**Requires at least:** 4.7 **Requires at least:** 4.7
**Tested up to:** 5.1.1 **Tested up to:** 5.1.1
**Stable tag:** 0.7.0 **Stable tag:** 0.7.1
**Requires PHP:** 5.6 **Requires PHP:** 5.6
**License:** MIT **License:** MIT
**License URI:** http://opensource.org/licenses/MIT **License URI:** http://opensource.org/licenses/MIT
@ -17,6 +17,13 @@ This is **BETA** software, see the FAQ to see the current feature set or rather
The plugin implements the ActivityPub protocol for your Blog. Your readers will be able to follow your Blogposts on Mastodon and other Federated Plattforms that support ActivityPub. The plugin implements the ActivityPub protocol for your Blog. Your readers will be able to follow your Blogposts on Mastodon and other Federated Plattforms that support ActivityPub.
The plugin works with the following federated plattforms:
* [mastodon](https://joinmastodon.org/)
* [pleroma](https://pleroma.social/)
* [friendi.ca](https://friendi.ca/)
* [hubzilla](https://hubzilla.org/)
## Frequently Asked Questions ## ## Frequently Asked Questions ##
### What is the status of this plugin? ### ### What is the status of this plugin? ###
@ -55,6 +62,10 @@ To implement:
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
### 0.7.1 ###
* fixed inbox problems with pleroma
### 0.7.0 ### ### 0.7.0 ###
* finally fixed pleroma compatibility * finally fixed pleroma compatibility

View file

@ -3,7 +3,7 @@
* Plugin Name: ActivityPub * Plugin Name: ActivityPub
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/ * Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format. * Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
* Version: 0.7.0 * Version: 0.7.1
* Author: Matthias Pfefferle * Author: Matthias Pfefferle
* Author URI: https://notiz.blog/ * Author URI: https://notiz.blog/
* License: MIT * License: MIT

View file

@ -79,6 +79,7 @@ class Activity {
'actor' => $this->actor, 'actor' => $this->actor,
'object' => $this->object, 'object' => $this->object,
'to' => $this->to, 'to' => $this->to,
'cc' => $this->cc,
); );
if ( $this->id ) { if ( $this->id ) {

View file

@ -61,7 +61,11 @@ function safe_remote_post( $url, $body, $user_id ) {
'body' => $body, 'body' => $body,
); );
return wp_safe_remote_post( $url, $args ); $response = wp_safe_remote_post( $url, $args );
do_action( 'activitypub_safe_remote_post_response', $response, $url, $body, $user_id );
return $response;
} }
/** /**
@ -85,8 +89,9 @@ function get_webfinger_resource( $user_id ) {
/** /**
* [get_metadata_by_actor description] * [get_metadata_by_actor description]
* *
* @param [type] $actor [description] * @param sting $actor
* @return [type] [description] *
* @return array
*/ */
function get_remote_metadata_by_actor( $actor ) { function get_remote_metadata_by_actor( $actor ) {
$metadata = get_transient( 'activitypub_' . $actor ); $metadata = get_transient( 'activitypub_' . $actor );
@ -177,13 +182,20 @@ function get_publickey_by_actor( $actor, $key_id ) {
return new \WP_Error( 'activitypub_no_public_key', __( 'No "Public-Key" found', 'activitypub' ), $metadata ); return new \WP_Error( 'activitypub_no_public_key', __( 'No "Public-Key" found', 'activitypub' ), $metadata );
} }
function get_follower_inboxes( $user_id, $followers ) { function get_follower_inboxes( $user_id ) {
$followers = \Activitypub\Db\Followers::get_followers( $user_id );
$inboxes = array(); $inboxes = array();
foreach ( $followers as $follower ) { foreach ( $followers as $follower ) {
$inboxes[] = \Activitypub\get_inbox_by_actor( $follower ); $inbox = \Activitypub\get_inbox_by_actor( $follower );
// init array if empty
if ( ! empty( $inboxes[ $inbox ] ) ) {
$inboxes[ $inbox ] = array();
}
$inboxes[ $inbox ][] = $follower;
} }
return array_unique( $inboxes ); return $inboxes;
} }
function get_identifier_settings( $user_id ) { function get_identifier_settings( $user_id ) {
@ -195,8 +207,9 @@ function get_identifier_settings( $user_id ) {
<label><?php esc_html_e( 'Profile identifier', 'activitypub' ); ?></label> <label><?php esc_html_e( 'Profile identifier', 'activitypub' ); ?></label>
</th> </th>
<td> <td>
<p><code><?php echo \Activitypub\get_webfinger_resource( $user_id ); ?></code> or <code><?php echo get_author_posts_url( $user_id ); ?></code></p> <p><code><?php echo esc_html( \Activitypub\get_webfinger_resource( $user_id ) ); ?></code> or <code><?php echo esc_url( get_author_posts_url( $user_id ) ); ?></code></p>
<p class="description"><?php printf( __( 'Try to follow "@%s" in the mastodon/friendi.ca search field.', 'activitypub' ), \Activitypub\get_webfinger_resource( $user_id ) ); ?></p> <?php // translators: the webfinger resource ?>
<p class="description"><?php printf( esc_html__( 'Try to follow "@%s" in the mastodon/friendi.ca search field.', 'activitypub' ), esc_html( \Activitypub\get_webfinger_resource( $user_id ) ) ); ?></p>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -139,12 +139,11 @@ class Outbox {
$activitypub_activity = new \Activitypub\Activity( 'Create', \Activitypub\Activity::TYPE_FULL ); $activitypub_activity = new \Activitypub\Activity( 'Create', \Activitypub\Activity::TYPE_FULL );
$activitypub_activity->from_post( $activitypub_post->to_array() ); $activitypub_activity->from_post( $activitypub_post->to_array() );
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
$activitypub_activity->set_to( $to );
$activity = $activitypub_activity->to_json(); // phpcs:ignore $activity = $activitypub_activity->to_json(); // phpcs:ignore
$followers = \Activitypub\Db\Followers::get_followers( $user_id ); \Activitypub\safe_remote_post( $inbox, $activity, $user_id );
foreach ( \Activitypub\get_follower_inboxes( $user_id, $followers ) as $inbox ) {
$response = \Activitypub\safe_remote_post( $inbox, $activity, $user_id );
} }
} }
@ -161,12 +160,11 @@ class Outbox {
$activitypub_activity = new \Activitypub\Activity( 'Update', \Activitypub\Activity::TYPE_FULL ); $activitypub_activity = new \Activitypub\Activity( 'Update', \Activitypub\Activity::TYPE_FULL );
$activitypub_activity->from_post( $activitypub_post->to_array() ); $activitypub_activity->from_post( $activitypub_post->to_array() );
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
$activitypub_activity->set_to( $to );
$activity = $activitypub_activity->to_json(); // phpcs:ignore $activity = $activitypub_activity->to_json(); // phpcs:ignore
$followers = \Activitypub\Db\Followers::get_followers( $user_id ); \Activitypub\safe_remote_post( $inbox, $activity, $user_id );
foreach ( \Activitypub\get_follower_inboxes( $user_id, $followers ) as $inbox ) {
$response = \Activitypub\safe_remote_post( $inbox, $activity, $user_id );
} }
} }
} }

View file

@ -2,9 +2,9 @@
# This file is distributed under the MIT. # This file is distributed under the MIT.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ActivityPub 0.6.0\n" "Project-Id-Version: ActivityPub 0.7.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n"
"POT-Creation-Date: 2019-03-12 21:22:31+00:00\n" "POT-Creation-Date: 2019-03-14 22:10:06+00:00\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
@ -79,27 +79,28 @@ msgstr ""
msgid "Unknown Actor schema" msgid "Unknown Actor schema"
msgstr "" msgstr ""
#: includes/functions.php:99 #: includes/functions.php:104
msgid "The \"actor\" is no valid URL" msgid "The \"actor\" is no valid URL"
msgstr "" msgstr ""
#: includes/functions.php:123 #: includes/functions.php:128
msgid "No valid JSON data" msgid "No valid JSON data"
msgstr "" msgstr ""
#: includes/functions.php:151 #: includes/functions.php:156
msgid "No \"Inbox\" found" msgid "No \"Inbox\" found"
msgstr "" msgstr ""
#: includes/functions.php:177 #: includes/functions.php:182
msgid "No \"Public-Key\" found" msgid "No \"Public-Key\" found"
msgstr "" msgstr ""
#: includes/functions.php:195 #: includes/functions.php:207
msgid "Profile identifier" msgid "Profile identifier"
msgstr "" msgstr ""
#: includes/functions.php:199 #: includes/functions.php:212
#. translators: the webfinger resource
msgid "Try to follow \"@%s\" in the mastodon/friendi.ca search field." msgid "Try to follow \"@%s\" in the mastodon/friendi.ca search field."
msgstr "" msgstr ""

View file

@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
Tags: OStatus, fediverse, activitypub, activitystream Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 5.1.1 Tested up to: 5.1.1
Stable tag: 0.7.0 Stable tag: 0.7.1
Requires PHP: 5.6 Requires PHP: 5.6
License: MIT License: MIT
License URI: http://opensource.org/licenses/MIT License URI: http://opensource.org/licenses/MIT
@ -17,6 +17,13 @@ This is **BETA** software, see the FAQ to see the current feature set or rather
The plugin implements the ActivityPub protocol for your Blog. Your readers will be able to follow your Blogposts on Mastodon and other Federated Plattforms that support ActivityPub. The plugin implements the ActivityPub protocol for your Blog. Your readers will be able to follow your Blogposts on Mastodon and other Federated Plattforms that support ActivityPub.
The plugin works with the following federated plattforms:
* [mastodon](https://joinmastodon.org/)
* [pleroma](https://pleroma.social/)
* [friendi.ca](https://friendi.ca/)
* [hubzilla](https://hubzilla.org/)
== Frequently Asked Questions == == Frequently Asked Questions ==
= What is the status of this plugin? = = What is the status of this plugin? =
@ -55,6 +62,10 @@ To implement:
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
= 0.7.1 =
* fixed inbox problems with pleroma
= 0.7.0 = = 0.7.0 =
* finally fixed pleroma compatibility * finally fixed pleroma compatibility