[TheFreeNetwork] First code: Module class and census event

This commit is contained in:
tenma 2019-10-30 23:09:38 +00:00 committed by Diogo Cordeiro
parent 1df9ec9f0f
commit 3634af3fdc
5 changed files with 92 additions and 0 deletions

View File

@ -336,6 +336,7 @@ $default =
'Favorite' => [],
'HTMLPurifierSchemes' => [],
'Share' => [],
'TheFreeNetwork' => [],
],
'default' => [
'AccountManager' => [],

View File

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

View File

@ -0,0 +1,65 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* TheFreeNetwork, "automagic" migration of internal remote profiles
* between different federation protocols.
*
* @package GNUsocial
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
* @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;
}
}

View File

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

View File

@ -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.