forked from GNUsocial/gnu-social
[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
1a4a1583d5
commit
c130739de0
@ -694,18 +694,16 @@ class ActivityPubPlugin extends Plugin
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
*/
|
||||
public function onStartSubscribe(Profile $profile, Profile $other) {
|
||||
if (!$profile->isLocal() && $other->isLocal()) {
|
||||
if (!$profile->isLocal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$other = Activitypub_profile::from_profile($other);
|
||||
} catch (Exception $e) {
|
||||
return true; // Let other plugin handle this instead
|
||||
$other = Activitypub_profile::getKV('profile_id', $other->getID());
|
||||
if (!$other instanceof Activitypub_profile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$postman = new Activitypub_postman($profile, array($other));
|
||||
|
||||
$postman = new Activitypub_postman($profile, [$other]);
|
||||
$postman->follow();
|
||||
|
||||
return true;
|
||||
@ -722,18 +720,16 @@ class ActivityPubPlugin extends Plugin
|
||||
*/
|
||||
public function onStartUnsubscribe(Profile $profile, Profile $other)
|
||||
{
|
||||
if (!$profile->isLocal() && $other->isLocal()) {
|
||||
if (!$profile->isLocal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$other = Activitypub_profile::from_profile($other);
|
||||
} catch (Exception $e) {
|
||||
return true; // Let other plugin handle this instead
|
||||
$other = Activitypub_profile::getKV('profile_id', $other->getID());
|
||||
if (!$other instanceof Activitypub_profile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$postman = new Activitypub_postman($profile, array($other));
|
||||
|
||||
$postman = new Activitypub_postman($profile, [$other]);
|
||||
$postman->undo_follow();
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user