From 1a4a1583d56dee8e1db5d1817505d62a3d0fc251 Mon Sep 17 00:00:00 2001 From: tenma Date: Sun, 25 Aug 2019 16:01:33 +0100 Subject: [PATCH] [AP] Subscribe RemoteFollow plugin events for allowing following with the remote-follow button --- plugins/ActivityPub/ActivityPubPlugin.php | 24 ++++++++++++++++++++++- plugins/ActivityPub/README.md | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/ActivityPub/ActivityPubPlugin.php b/plugins/ActivityPub/ActivityPubPlugin.php index 49cf5f8dd8..3bb4012407 100644 --- a/plugins/ActivityPub/ActivityPubPlugin.php +++ b/plugins/ActivityPub/ActivityPubPlugin.php @@ -50,7 +50,7 @@ const ACTIVITYPUB_PUBLIC_TO = ['https://www.w3.org/ns/activitystreams#Public', */ class ActivityPubPlugin extends Plugin { - const PLUGIN_VERSION = '0.1.0alpha0'; + const PLUGIN_VERSION = '0.2.0alpha0'; /** * Returns a Actor's URI from its local $profile @@ -657,6 +657,28 @@ class ActivityPubPlugin extends Plugin } } + /** + * Try to grab and store the remote profile by the given uri + * + * @param string $uri + * @param Profile &$profile + * @return bool + */ + public function onRemoteFollowPullProfile(string $uri, ?Profile &$profile): bool + { + try { + $aprofile = $this->pull_remote_profile($uri); + if ($aprofile instanceof Activitypub_profile) { + $profile = $aprofile->local_profile(); + } + } catch (Exception $e) { + // No remote ActivityPub profile found + return true; + } + + return is_null($profile); + } + /******************************************************** * Delivery Events * ********************************************************/ diff --git a/plugins/ActivityPub/README.md b/plugins/ActivityPub/README.md index 270aa96d5f..94029589dd 100644 --- a/plugins/ActivityPub/README.md +++ b/plugins/ActivityPub/README.md @@ -8,6 +8,11 @@ It includes general information about the plugin. This plugin adds [ActivityPub](https://www.w3.org/TR/activitypub/) support to GNU social. +## Additional functionality + +The RemoteFollow plugin is recommended as it increases the UX significatively, +it adds a remote follow button to user profiles. + ## Credits * **[Diogo Cordeiro](https://www.diogo.site/)**