]> git.mxchange.org Git - friendica.git/commitdiff
Reliably diasplay "like" and "share" notifications
authorMichael <heluecht@pirati.ca>
Mon, 23 Aug 2021 15:07:14 +0000 (15:07 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 23 Aug 2021 15:07:14 +0000 (15:07 +0000)
include/enotify.php
mod/ping.php
src/Model/Notification.php

index d77ab448af5d59dbb8f7120677fe4370b8db93d6..7eae51a0b5f2c86e3efcb1ff66f839124f55139c 100644 (file)
@@ -605,7 +605,10 @@ function notification_store_and_send($params, $sitelink, $tsitelink, $hsitelink,
 
 function notification_from_array(array $notification)
 {
+       Logger::info('Start', ['uid' => $notification['uid'], 'id' => $notification['id'], 'type' => $notification['type']]);
+
        if ($notification['type'] == Post\UserNotification::NOTIF_NONE) {
+               Logger::info('Not an item based notification, quitting', ['uid' => $notification['uid'], 'id' => $notification['id'], 'type' => $notification['type']]);
                return false;
        }
 
@@ -636,6 +639,7 @@ function notification_from_array(array $notification)
                ['uid' => [0, $notification['uid']], 'uri-id' => $notification['target-uri-id'], 'deleted' => false],
                ['order' => ['uid' => true]]);
        if (empty($item)) {
+               Logger::info('Item not found', ['uri-id' => $notification['target-uri-id'], 'type' => $notification['type']]);
                return false;
        }
 
@@ -646,15 +650,16 @@ function notification_from_array(array $notification)
        $subjectPrefix = $l10n->t('[Friendica:Notify]');
 
        if (Post\ThreadUser::getIgnored($notification['parent-uri-id'], $notification['uid'])) {
-               Logger::info('Thread is ignored', ['parent-uri-id' => $notification['parent-uri-id']]);
+               Logger::info('Thread is ignored', ['parent-uri-id' => $notification['parent-uri-id'], 'type' => $notification['type']]);
                return false;
        }
 
        // Check to see if there was already a tag notify or comment notify for this post.
        // If so don't create a second notification
        $condition = ['type' => [Notification\Type::TAG_SELF, Notification\Type::COMMENT, Notification\Type::SHARE],
-               'link' => $params['link'], 'uid' => $notification['uid']];
+               'link' => $params['link'], 'verb' => Activity::POST, 'uid' => $notification['uid']];
        if (DBA::exists('notify', $condition)) {
+               Logger::info('Duplicate found, quitting', $condition);
                return false;
        }
 
@@ -682,6 +687,7 @@ function notification_from_array(array $notification)
 
        $msg = Notification::getMessage($notification);
        if (empty($msg)) {
+               Logger::info('No notification message, quitting', ['uid' => $notification['uid'], 'id' => $notification['id'], 'type' => $notification['type']]);
                return false;
        }
 
@@ -696,6 +702,8 @@ function notification_from_array(array $notification)
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink  = $params['link'];
 
+       Logger::info('Perform notification', ['uid' => $notification['uid'], 'id' => $notification['id'], 'type' => $notification['type']]);
+
        return notification_store_and_send($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $item['body'], $itemlink, true);
 }
 
index bdd30be3fc10100679884a1803df353fb2a8d1c6..8a74f852c28fd8905a2357b46b77254f23f0cff7 100644 (file)
@@ -462,10 +462,10 @@ function ping_get_notifications($uid)
                                && empty($result[$notification['parent']])
                        ) {
                                // Should we condense the notifications or show them all?
-                               if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
-                                       $result[$notification["id"]] = $notification;
+                               if (($notification['verb'] != Activity::POST) || DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
+                                       $result[] = $notification;
                                } else {
-                                       $result[$notification['parent']] = $notification;
+                                       $result['p:' . $notification['parent']] = $notification;
                                }
                        }
                }
index 2a730c5db1fd7b60bc3b6c9ea159e03fa2944fdf..1df420845c7b610a7be2c6112361b6f28c82a1c4 100644 (file)
@@ -222,10 +222,17 @@ class Notification extends BaseModel
                                }
                        }
 
-                       if (($notification['type'] == Post\UserNotification::NOTIF_SHARED) && !empty($item['causer-id'])) {
-                               $causer = Contact::getById($item['causer-id'], ['id', 'name', 'url']);
+                       if ($item['owner-id'] != $item['author-id']) {
+                               $cid = $item['owner-id'];
+                       }
+                       if (!empty($item['causer-id']) && ($item['causer-id'] != $item['author-id'])) {
+                               $cid = $item['causer-id'];
+                       }
+
+                       if (($notification['type'] == Post\UserNotification::NOTIF_SHARED) && !empty($cid)) {
+                               $causer = Contact::getById($cid, ['id', 'name', 'url']);
                                if (empty($contact)) {
-                                       Logger::info('Causer not found', ['causer' => $item['causer-id']]);
+                                       Logger::info('Causer not found', ['causer' => $cid]);
                                        return $message;
                                }
                        } elseif (in_array($notification['type'], [Post\UserNotification::NOTIF_COMMENT_PARTICIPATION, Post\UserNotification::NOTIF_ACTIVITY_PARTICIPATION])) {