]> git.mxchange.org Git - friendica.git/commitdiff
Delete follow notification on unfollow
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 6 Mar 2022 11:36:39 +0000 (06:36 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 14 Mar 2022 11:58:39 +0000 (07:58 -0400)
- Fix translation string typo

src/Model/Contact.php
src/Navigation/Notifications/Factory/Notification.php
src/Navigation/Notifications/Repository/Notification.php

index cdb347e8be253ea8699e59fa69aa4312da313f7b..e1152b4081950efe5d4ede4ba69edf69312ea530 100644 (file)
@@ -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']]);
        }
 
        /**
index 50180a9203283c831cbaad2f18e11fd50a106549..b404ad8671d7e6c357e6f3681ba143c43f245cf9 100644 (file)
@@ -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'];
index 57f85054de85089c6e15991be8e3c1f331494460..290845645a508e3dbf157f6fe6195b2b39ef8cec 100644 (file)
@@ -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);
+       }
 }