[ActivityPub] Fix some small known problems
ActivityPubPlugin: - Rework onProfileDeleteRelated to account for the tables _rsa and _pending_follow_requests - Update onEndShowAccountProfileBlock to stop creating the ap_profile if it doesn't exist (we'll handle this in a different manner) Activitypub_profile: - Remove unnecessary code from from_profile method and add return type information Explorer: - Update travel_collection to call itself instead of _lookup, that was wrong
This commit is contained in:
parent
b3c2dfd9c9
commit
6a37c21ead
@ -345,18 +345,17 @@ class ActivityPubPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
public function onProfileDeleteRelated(Profile $profile, array &$related): void
|
public function onProfileDeleteRelated(Profile $profile, array &$related): void
|
||||||
{
|
{
|
||||||
if ($profile->isLocal()) {
|
$related[] = 'Activitypub_profile';
|
||||||
return;
|
$related[] = 'Activitypub_rsa';
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
// pending_follow_requests doesn't have a profile_id column,
|
||||||
$aprofile = Activitypub_profile::getKV('profile_id', $profile->getID());
|
// so we must handle it manually
|
||||||
if ($aprofile instanceof Activitypub_profile) {
|
$follow = new Activitypub_pending_follow_requests(null, $profile->getID());
|
||||||
// mark for deletion
|
|
||||||
$related[] = 'Activitypub_profile';
|
if ($follow->find()) {
|
||||||
|
while ($follow->fetch()) {
|
||||||
|
$follow->delete();
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,9 +385,9 @@ class ActivityPubPlugin extends Plugin
|
|||||||
if ($profile->isLocal()) {
|
if ($profile->isLocal()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
Activitypub_profile::from_profile($profile);
|
$aprofile = Activitypub_profile::getKV('profile_id', $profile->getID());
|
||||||
} catch (Exception $e) {
|
if (!$aprofile instanceof Activitypub_profile) {
|
||||||
// Not a remote ActivityPub_profile! Maybe some other network
|
// Not a remote ActivityPub_profile! Maybe some other network
|
||||||
// that has imported a non-local user (e.g.: OStatus)?
|
// that has imported a non-local user (e.g.: OStatus)?
|
||||||
return true;
|
return true;
|
||||||
|
@ -201,7 +201,7 @@ class Activitypub_profile extends Managed_DataObject
|
|||||||
* @throws Exception if no Activitypub_profile exists for given Profile
|
* @throws Exception if no Activitypub_profile exists for given Profile
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
*/
|
*/
|
||||||
public static function from_profile(Profile $profile)
|
public static function from_profile(Profile $profile): Activitypub_profile
|
||||||
{
|
{
|
||||||
$profile_id = $profile->getID();
|
$profile_id = $profile->getID();
|
||||||
|
|
||||||
@ -216,8 +216,9 @@ class Activitypub_profile extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extend the ap_profile with some information we
|
||||||
|
// don't store in the database
|
||||||
$fields = [
|
$fields = [
|
||||||
'uri' => 'profileurl',
|
|
||||||
'nickname' => 'nickname',
|
'nickname' => 'nickname',
|
||||||
'fullname' => 'fullname',
|
'fullname' => 'fullname',
|
||||||
'bio' => 'bio'
|
'bio' => 'bio'
|
||||||
|
@ -450,7 +450,7 @@ class Activitypub_explorer
|
|||||||
}
|
}
|
||||||
// Go through entire collection
|
// Go through entire collection
|
||||||
if (!is_null($res["next"])) {
|
if (!is_null($res["next"])) {
|
||||||
$this->_lookup($res["next"]);
|
$this->travel_collection($res["next"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user