[AP] Subscribe RemoteFollow plugin events for allowing following with the remote-follow button

This commit is contained in:
tenma 2019-08-25 16:01:33 +01:00 committed by Diogo Cordeiro
parent 3633ca04eb
commit 1a4a1583d5
2 changed files with 28 additions and 1 deletions

View File

@ -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 *
********************************************************/

View File

@ -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/)**