Issue 11566: More detailled notification configuration

This commit is contained in:
Michael 2022-06-05 11:41:08 +00:00
parent b1afcb5ebf
commit 57b8708425
10 changed files with 338 additions and 240 deletions

View file

@ -148,7 +148,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
return $message;
}
if (in_array($Notification->type, [Post\UserNotification::TYPE_THREAD_COMMENT, Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_EXPLICIT_TAGGED])) {
if (in_array($Notification->type, [Post\UserNotification::TYPE_THREAD_COMMENT, Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_FOLLOW, Post\UserNotification::TYPE_EXPLICIT_TAGGED])) {
$item = Post::selectFirst([], ['uri-id' => $Notification->parentUriId, 'uid' => [0, $Notification->uid]], ['order' => ['uid' => true]]);
if (empty($item)) {
$this->logger->info('Parent post not found', ['uri-id' => $Notification->parentUriId]);
@ -175,7 +175,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
}
}
if (in_array($Notification->type, [Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_SHARED])) {
if (in_array($Notification->type, [Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_FOLLOW, Post\UserNotification::TYPE_SHARED])) {
$author = Contact::getById($item['author-id'], ['id', 'name', 'url', 'contact-type']);
if (empty($author)) {
$this->logger->info('Author not found', ['author' => $item['author-id']]);
@ -276,6 +276,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
case Post\UserNotification::TYPE_COMMENT_PARTICIPATION:
case Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION:
case Post\UserNotification::TYPE_FOLLOW;
if (($causer['id'] == $author['id']) && ($title != '')) {
$msg = $l10n->t('%1$s commented in their thread %2$s');
} elseif ($causer['id'] == $author['id']) {

View file

@ -663,7 +663,7 @@ class Notify extends BaseRepository
$type = \Friendica\Factory\Api\Mastodon\Notification::getType($Notification);
}
if (!in_array($type, [Notification::TYPE_RESHARE, Notification::TYPE_LIKE])) {
if (in_array($Notification->type, [Model\Post\UserNotification::TYPE_FOLLOW])) {
return true;
}
@ -675,6 +675,24 @@ class Notify extends BaseRepository
return true;
}
$notify_type = $this->pConfig->get(local_user(), 'system', 'notify_type', 3 | 72 | 4 | 16 | 32);
if (($notify_type & 3) && in_array($Notification->type, [Model\Post\UserNotification::TYPE_EXPLICIT_TAGGED, Model\Post\UserNotification::TYPE_IMPLICIT_TAGGED])) {
return true;
}
if (($notify_type & 72) && in_array($Notification->type, [Model\Post\UserNotification::TYPE_DIRECT_COMMENT, Model\Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT])) {
return true;
}
if (($notify_type & 4) && in_array($Notification->type, [Model\Post\UserNotification::TYPE_THREAD_COMMENT])) {
return true;
}
if (($notify_type & 16) && in_array($Notification->type, [Model\Post\UserNotification::TYPE_COMMENT_PARTICIPATION])) {
return true;
}
if (($notify_type & 32) && in_array($Notification->type, [Model\Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION])) {
return true;
}
return false;
}