Fix various Notices

This commit is contained in:
Philipp Holzer 2021-09-13 20:22:55 +02:00
parent 9b19fb9b4d
commit 644f312896
Signed by: nupplaPhil
GPG Key ID: 24A7501396EB5432
7 changed files with 12 additions and 10 deletions

View File

@ -2757,12 +2757,14 @@ class Contact
return null; return null;
} }
public static function removeFollower($importer, $contact) public static function removeFollower(array $contact)
{ {
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) { if (!empty($contact['rel']) && (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING))) {
DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]); DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
} else { } elseif (!empty($contact['id'])) {
self::remove($contact['id']); self::remove($contact['id']);
} else {
DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact]);
} }
} }

View File

@ -2292,9 +2292,9 @@ class Item
continue; continue;
} elseif (!$expire_starred && intval($item['starred'])) { } elseif (!$expire_starred && intval($item['starred'])) {
continue; continue;
} elseif (!$expire_notes && ($item['post-type'] == self::PT_PERSONAL_NOTE)) { } elseif (!$expire_notes && (($item['post-type'] ?? null) == self::PT_PERSONAL_NOTE)) {
continue; continue;
} elseif (!$expire_items && ($item['post-type'] != self::PT_PERSONAL_NOTE)) { } elseif (!$expire_items && (($item['post-type'] ?? null) != self::PT_PERSONAL_NOTE)) {
continue; continue;
} }

View File

@ -293,7 +293,7 @@ class Contact extends BaseModule
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
// Don't display contacts that are about to be deleted // Don't display contacts that are about to be deleted
if ($contact['network'] == Protocol::PHANTOM) { if (DBA::isResult($contact) && !empty($contact['network']) && $contact['network'] == Protocol::PHANTOM) {
$contact = false; $contact = false;
} }
} }

View File

@ -1102,7 +1102,7 @@ class Processor
return; return;
} }
Contact::removeFollower($owner, $contact); Contact::removeFollower($contact);
Logger::info('Undo following request', ['contact' => $cid, 'user' => $uid]); Logger::info('Undo following request', ['contact' => $cid, 'user' => $uid]);
} }

View File

@ -1584,7 +1584,7 @@ class DFRN
} }
if ($activity->match($item["verb"], Activity::UNFOLLOW)) { if ($activity->match($item["verb"], Activity::UNFOLLOW)) {
Logger::log("Lost follower"); Logger::log("Lost follower");
Contact::removeFollower($importer, $contact, $item); Contact::removeFollower($contact);
return false; return false;
} }
if ($activity->match($item["verb"], Activity::REQ_FRIEND)) { if ($activity->match($item["verb"], Activity::REQ_FRIEND)) {

View File

@ -2211,7 +2211,7 @@ class Diaspora
return true; return true;
} else { } else {
Logger::log("Author ".$author." doesn't want to follow us anymore.", Logger::DEBUG); Logger::log("Author ".$author." doesn't want to follow us anymore.", Logger::DEBUG);
Contact::removeFollower($importer, $contact); Contact::removeFollower($contact);
return true; return true;
} }
} }

View File

@ -471,7 +471,7 @@ class OStatus
if ($item["verb"] == Activity::O_UNFOLLOW) { if ($item["verb"] == Activity::O_UNFOLLOW) {
$dummy = null; $dummy = null;
Contact::removeFollower($importer, $contact, $item, $dummy); Contact::removeFollower($contact);
continue; continue;
} }