diff --git a/lib/util/default.php b/lib/util/default.php index 6c94960f5e..cfe27010fb 100644 --- a/lib/util/default.php +++ b/lib/util/default.php @@ -336,6 +336,7 @@ $default = 'Favorite' => [], 'HTMLPurifierSchemes' => [], 'Share' => [], + 'TheFreeNetwork' => [], ], 'default' => [ 'AccountManager' => [], diff --git a/modules/TheFreeNetwork/EVENTS.txt b/modules/TheFreeNetwork/EVENTS.txt new file mode 100644 index 0000000000..35b312019b --- /dev/null +++ b/modules/TheFreeNetwork/EVENTS.txt @@ -0,0 +1,2 @@ +StartTFNCensus: when all plugins have been initialized; federation plugins must populate this event's array with their profile class name +@param array $free_network \ No newline at end of file diff --git a/modules/TheFreeNetwork/TheFreeNetworkModule.php b/modules/TheFreeNetwork/TheFreeNetworkModule.php new file mode 100644 index 0000000000..964cb5d7ed --- /dev/null +++ b/modules/TheFreeNetwork/TheFreeNetworkModule.php @@ -0,0 +1,65 @@ +. + +/** + * TheFreeNetwork, "automagic" migration of internal remote profiles + * between different federation protocols. + * + * @package GNUsocial + * @author Bruno Casteleiro + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +defined('GNUSOCIAL') || die(); + +class TheFreeNetworkModule extends Module +{ + const MODULE_VERSION = '0.1.0alpha0'; + + private $free_network = []; // name of the profile classes of the active federation protocols + + /** + * Called when all plugins have been initialized + * We'll populate the $free_network array here + * + * @return boolean hook value + */ + public function onInitializePlugin() + { + Event::handle('StartTFNCensus', [&$this->free_network]); + return true; + } + + /** + * Plugin version information + * + * @param array $versions + * @return bool hook true + */ + public function onPluginVersion(array &$versions): bool + { + $versions[] = [ + 'name' => 'TheFreeNetwork', + 'version' => self::MODULE_VERSION, + 'author' => 'Bruno Casteleiro', + 'homepage' => 'https://notabug.org/diogo/gnu-social/src/nightly/plugins/TheFreeNetwork', + // TRANS: Module description. + 'rawdescription' => '"Automagically" migrate internal remote profiles between different federation protocols' + ]; + return true; + } +} \ No newline at end of file diff --git a/plugins/ActivityPub/ActivityPubPlugin.php b/plugins/ActivityPub/ActivityPubPlugin.php index bd2df077ab..bba73b13cd 100644 --- a/plugins/ActivityPub/ActivityPubPlugin.php +++ b/plugins/ActivityPub/ActivityPubPlugin.php @@ -230,6 +230,18 @@ class ActivityPubPlugin extends Plugin return true; } + /** + * Subscribe AP's profile class to the TFN module + * + * @param array $federation + * @return bool event hook return + */ + public function onStartTFNCensus(array &$federation): bool + { + $federation[] = 'Activitypub_profile'; + return true; + } + /** * Set up queue handlers for required interactions * diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 941a67af52..091fa61027 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -1440,6 +1440,18 @@ class OStatusPlugin extends Plugin return true; } + /** + * Subscribe OS's profile class to the TFN module + * + * @param array $federation + * @return bool event hook return + */ + public function onStartTFNCensus(array &$federation): bool + { + $federation[] = 'Ostatus_profile'; + return true; + } + /** * Utility function to check if the given URI is a canonical group profile * page, and if so return the ID number.