[AP] Fix subscription events
Both StartSubscribe and StartUnsubscribe had a wrong initial if-condition. Furthermore, this events were calling Activitypub_profile::from_profile() which is wrong because it creates the Activitypub_profile object when the goal is only to check if it exists already.
This commit is contained in:
parent
6af86536aa
commit
58a9c71391
|
@ -694,18 +694,16 @@ class ActivityPubPlugin extends Plugin
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
*/
|
*/
|
||||||
public function onStartSubscribe(Profile $profile, Profile $other) {
|
public function onStartSubscribe(Profile $profile, Profile $other) {
|
||||||
if (!$profile->isLocal() && $other->isLocal()) {
|
if (!$profile->isLocal()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$other = Activitypub_profile::getKV('profile_id', $other->getID());
|
||||||
$other = Activitypub_profile::from_profile($other);
|
if (!$other instanceof Activitypub_profile) {
|
||||||
} catch (Exception $e) {
|
return true;
|
||||||
return true; // Let other plugin handle this instead
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$postman = new Activitypub_postman($profile, array($other));
|
$postman = new Activitypub_postman($profile, [$other]);
|
||||||
|
|
||||||
$postman->follow();
|
$postman->follow();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -722,18 +720,16 @@ class ActivityPubPlugin extends Plugin
|
||||||
*/
|
*/
|
||||||
public function onStartUnsubscribe(Profile $profile, Profile $other)
|
public function onStartUnsubscribe(Profile $profile, Profile $other)
|
||||||
{
|
{
|
||||||
if (!$profile->isLocal() && $other->isLocal()) {
|
if (!$profile->isLocal()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$other = Activitypub_profile::getKV('profile_id', $other->getID());
|
||||||
$other = Activitypub_profile::from_profile($other);
|
if (!$other instanceof Activitypub_profile) {
|
||||||
} catch (Exception $e) {
|
return true;
|
||||||
return true; // Let other plugin handle this instead
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$postman = new Activitypub_postman($profile, array($other));
|
$postman = new Activitypub_postman($profile, [$other]);
|
||||||
|
|
||||||
$postman->undo_follow();
|
$postman->undo_follow();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user