Use public contact ID in Model\Post\UserNotification::insertNotification

- Add localRelationship dependency to Notification factory
- Remove dependencies from Factory\Notification->getMessageFromNotification method
This commit is contained in:
Hypolite Petovan 2022-03-03 08:49:07 -05:00
parent 7ce97459d4
commit deafdcde95
8 changed files with 105 additions and 70 deletions

View file

@ -2665,7 +2665,7 @@ class Contact
// Ensure to always have the correct network type, independent from the connection request method
self::updateFromProbe($contact['id']);
Post\UserNotification::insertNotification($contact['id'], Activity::FOLLOW, $importer['uid']);
Post\UserNotification::insertNotification($pub_contact['id'], Activity::FOLLOW, $importer['uid']);
return true;
} else {
@ -2696,7 +2696,7 @@ class Contact
self::updateAvatar($contact_id, $photo, true);
Post\UserNotification::insertNotification($contact_id, Activity::FOLLOW, $importer['uid']);
Post\UserNotification::insertNotification($pub_contact['id'], Activity::FOLLOW, $importer['uid']);
$contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]);
@ -2716,9 +2716,7 @@ class Contact
Group::addMember(User::getDefaultGroup($importer['uid']), $contact_record['id']);
if (($user['notify-flags'] & Notification\Type::INTRO) &&
in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) {
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
DI::notify()->createFromArray([
'type' => Notification\Type::INTRO,
'otype' => Notification\ObjectType::INTRO,

View file

@ -308,7 +308,7 @@ class UserNotification
return;
}
$notification = (new Notifications\Factory\Notification(DI::logger()))->createForUser(
$notification = (new Notifications\Factory\Notification(DI::baseUrl(), DI::l10n(), DI::localRelationship(), DI::logger()))->createForUser(
$uid,
$item['vid'],
$type,
@ -328,7 +328,7 @@ class UserNotification
/**
* Add a notification entry
*
* @param int $actor Contact ID of the actor
* @param int $actor Public contact ID of the actor
* @param string $verb One of the Activity verb constant values
* @param int $uid User ID
* @return boolean
@ -336,7 +336,7 @@ class UserNotification
*/
public static function insertNotification(int $actor, string $verb, int $uid): bool
{
$notification = (new Notifications\Factory\Notification(DI::logger()))->createForRelationship(
$notification = (new Notifications\Factory\Notification(DI::baseUrl(), DI::l10n(), DI::localRelationship(), DI::logger()))->createForRelationship(
$uid,
$actor,
$verb