Delete follow notification on unfollow

- Fix translation string typo
This commit is contained in:
Hypolite Petovan 2022-03-06 06:36:39 -05:00
parent 49971b1465
commit e6f745bcb1
3 changed files with 16 additions and 2 deletions

View file

@ -2617,7 +2617,7 @@ class Contact
return false; 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']]); $pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if (!DBA::isResult($pub_contact)) { if (!DBA::isResult($pub_contact)) {
// Should never happen // Should never happen
@ -2762,6 +2762,10 @@ class Contact
} else { } else {
DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact, 'callstack' => System::callstack()]); 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']]);
} }
/** /**

View file

@ -118,7 +118,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
if ($localRelationship->pending) { if ($localRelationship->pending) {
$msg = $this->l10n->t('%1$s wants to follow you'); $msg = $this->l10n->t('%1$s wants to follow you');
} else { } else {
$msg = $this->l10n->t('%1$s had started following you'); $msg = $this->l10n->t('%1$s has started following you');
} }
$title = $causer['name']; $title = $causer['name'];

View file

@ -195,4 +195,14 @@ class Notification extends BaseRepository
return $Notification; 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);
}
} }