From e6f745bcb1f3f8ebf0d2e69f28a0ee617a785633 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 6 Mar 2022 06:36:39 -0500 Subject: [PATCH] Delete follow notification on unfollow - Fix translation string typo --- src/Model/Contact.php | 6 +++++- src/Navigation/Notifications/Factory/Notification.php | 2 +- .../Notifications/Repository/Notification.php | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index cdb347e8be..e1152b4081 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2617,7 +2617,7 @@ class Contact return false; } - $fields = ['url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked']; + $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked']; $pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]); if (!DBA::isResult($pub_contact)) { // Should never happen @@ -2762,6 +2762,10 @@ class Contact } else { DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact, 'callstack' => System::callstack()]); } + + $cdata = Contact::getPublicAndUserContactID($contact['id'], $contact['uid']); + + DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]); } /** diff --git a/src/Navigation/Notifications/Factory/Notification.php b/src/Navigation/Notifications/Factory/Notification.php index 50180a9203..b404ad8671 100644 --- a/src/Navigation/Notifications/Factory/Notification.php +++ b/src/Navigation/Notifications/Factory/Notification.php @@ -118,7 +118,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow if ($localRelationship->pending) { $msg = $this->l10n->t('%1$s wants to follow you'); } else { - $msg = $this->l10n->t('%1$s had started following you'); + $msg = $this->l10n->t('%1$s has started following you'); } $title = $causer['name']; diff --git a/src/Navigation/Notifications/Repository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php index 57f85054de..290845645a 100644 --- a/src/Navigation/Notifications/Repository/Notification.php +++ b/src/Navigation/Notifications/Repository/Notification.php @@ -195,4 +195,14 @@ class Notification extends BaseRepository return $Notification; } + + public function deleteForUserByVerb(int $uid, string $verb, array $condition = []): bool + { + $condition['uid'] = $uid; + $condition['vid'] = Verb::getID($verb); + + $this->logger->notice('deleteForUserByVerb', ['condition' => $condition]); + + return $this->db->delete(self::$table_name, $condition); + } }