[ActivityPub][SCRIPTS] Make update profiles work with an uri
This commit is contained in:
parent
e504d13120
commit
1967f46a69
|
@ -488,7 +488,7 @@ class Activitypub_profile extends Managed_DataObject
|
||||||
* @throws NoProfileException
|
* @throws NoProfileException
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
*/
|
*/
|
||||||
public static function update_profile($aprofile, $res)
|
public static function update_profile(Activitypub_profile $aprofile, array $res): Profile
|
||||||
{
|
{
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
$profile = $aprofile->local_profile();
|
$profile = $aprofile->local_profile();
|
||||||
|
|
|
@ -53,13 +53,7 @@ if (!$quiet) {
|
||||||
|
|
||||||
if (have_option('u', 'uri')) {
|
if (have_option('u', 'uri')) {
|
||||||
$uri = get_option_value('u', 'uri');
|
$uri = get_option_value('u', 'uri');
|
||||||
$discovery = new Activitypub_explorer();
|
$user = Activitypub_profile::from_profile(Activitypub_explorer::get_profile_from_url($uri));
|
||||||
$discovery = $discovery->lookup($uri);
|
|
||||||
if (empty($discovery)) {
|
|
||||||
echo "Bad URI\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
$user = $discovery->lookup($uri)[0];
|
|
||||||
try {
|
try {
|
||||||
$res = Activitypub_explorer::get_remote_user_activity($uri);
|
$res = Activitypub_explorer::get_remote_user_activity($uri);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -67,8 +61,9 @@ if (have_option('u', 'uri')) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!$quiet) {
|
if (!$quiet) {
|
||||||
echo "Updated ".Activitypub_profile::update_profile($user, $res)->getBestName()."\n";
|
echo 'Updated '.Activitypub_profile::update_profile($user, $res)->getBestName()."\n";
|
||||||
}
|
}
|
||||||
|
exit(0);
|
||||||
} elseif (!have_option('a', 'all')) {
|
} elseif (!have_option('a', 'all')) {
|
||||||
show_help();
|
show_help();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user