[ActivityPub] Fix wrong type handling on AProfile:update_profile

This commit is contained in:
Diogo Cordeiro 2020-07-21 12:01:56 +01:00 committed by Diogo Peralta Cordeiro
parent f1b3db8e59
commit 05790c124c

View File

@ -489,7 +489,7 @@ class Activitypub_profile extends Managed_DataObject
* @throws NoProfileException
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public static function update_profile(Activitypub_profile $aprofile, array $res): Profile
public static function update_profile(Activitypub_profile $aprofile, $res): Profile
{
if ($res === false) {
$profile = $aprofile->local_profile();
@ -498,6 +498,10 @@ class Activitypub_profile extends Managed_DataObject
throw new NoProfileException($id, "410 Gone");
}
if (!is_array($res)) {
throw new InvalidArgumentException('TypeError: Argument 2 passed to Activitypub_profile::update_profile() must be of the type array or bool(false).');
}
// ActivityPub Profile
$aprofile->uri = $res['id'];
$aprofile->nickname = $res['preferredUsername'];