[OStatus] Add script for profile deduplication and URI fixing

This commit is contained in:
tenma
2019-10-24 02:08:54 +01:00
committed by Diogo Cordeiro
parent a0d30b6872
commit 69add504e6
4 changed files with 244 additions and 0 deletions

View File

@@ -1719,4 +1719,36 @@ class OStatusPlugin extends Plugin
return is_null($profile);
}
/**
* To be consistent with the ActivityPub protocol, we need to make sure that
* all ostatus profiles are unique and use non-fancy URIs. This method executes
* an external script to ensure that conditions.
*
* @return bool hook flag
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
*/
public function onEndUpgrade(): bool
{
$flag = __DIR__ . DIRECTORY_SEPARATOR . '.ostatus_version.txt';
$script = __DIR__ . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'updateuris.php';
if (!file_exists($flag)) {
// If our flag-file isn't set then we know OStatus hasn't upgraded yet,
// run external script and plant the flag
define('OSTATUS_UPGRADE', true);
require_once $script;
$file = fopen($flag, "w");
if ($file === false) {
$this->log(LOG_ERR, "Failed to create the file: {$flag}\n");
} else {
fwrite($file, self::PLUGIN_VERSION . PHP_EOL);
fclose($file);
}
}
return true;
}
}