minor fixes for testing-file

This commit is contained in:
Yannis Vogel 2025-06-11 18:16:43 +02:00
parent 2ae81a3748
commit 61f6fe3e7b
No known key found for this signature in database

View file

@ -91,6 +91,9 @@ class Test
// pretend that we are running from web directory // pretend that we are running from web directory
define('PROJECT_ROOT', dirname(__DIR__, 2)); define('PROJECT_ROOT', dirname(__DIR__, 2));
$api = new \Federator\Api(); $api = new \Federator\Api();
$api->loadPlugins();
$api->openDatabase();
for ($i = 1; $i < $argc; ++$i) { for ($i = 1; $i < $argc; ++$i) {
switch ($argv[$i]) { switch ($argv[$i]) {
case 'fetchoutbox': case 'fetchoutbox':
@ -109,18 +112,18 @@ class Test
/** /**
* print usage of maintenance tool * print usage of test tool
* *
* @return void * @return void
*/ */
public static function printUsage() public static function printUsage()
{ {
echo "usage php maintenance.php <command> <parameter> [<command> <parameter>...]\n"; echo "usage php test.php <command> <parameter> [<command> <parameter>...]\n";
echo "command can be one of:\n"; echo "command can be one of:\n";
echo " fetchoutbox - fetch users outbox. parameter: username\n"; echo " fetchoutbox - fetch users outbox. parameter: username\n";
echo " upvote - upvote. parameter: URL to upvote\n"; echo " upvote - upvote. parameter: URL to upvote\n";
echo " downvote - downvote. parameter: URL to downvote\n"; echo " downvote - downvote. parameter: URL to downvote\n";
echo " comment - downvote. parameter: URL to comment, text to comment\n"; echo " comment - comment. parameter: URL to comment, text to comment\n";
echo " Run this after you updated the program files\n"; echo " Run this after you updated the program files\n";
exit(); exit();
} }
@ -136,13 +139,16 @@ class Test
public static function upvote($api, $_url) public static function upvote($api, $_url)
{ {
$dbh = $api->getDatabase(); $dbh = $api->getDatabase();
$inboxActivity = new \Federator\Data\ActivityPub\Common\Create(); $inboxActivity = new \Federator\Data\ActivityPub\Common\Like();
$inboxActivity->setAActor('https://mastodon.local/users/admin');
$inboxActivity->setObject($_url);
$inboxActivity->setID("https://mastodon.local/users/admin#like/" . md5($_url));
\Federator\Api\FedUsers\Inbox::postForUser( \Federator\Api\FedUsers\Inbox::postForUser(
$dbh, $dbh,
$api->getConnector(), $api->getConnector(),
null, null,
'grumpydevelop', 'admin@mastodon.local',
$_url, "grumpydevelop@192.168.178.143",
$inboxActivity $inboxActivity
); );
} }