]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Bugfix: Only send a notifier when the item was really edited
[friendica.git] / src / Model / Item.php
index dfb7ea065cfd4ac736198e69f4380f91877fadfa..0a480d755bdf224997f23aca92a9d84025e4f920 100644 (file)
@@ -75,8 +75,9 @@ class Item extends BaseObject
                        Term::insertFromFileFieldByItemId($item['id']);
                        self::updateThread($item['id']);
 
-                       // We only need to notfiy others when it is an original entry from us
-                       if ($item['origin']) {
+                       // We only need to notfiy others when it is an original entry from us.
+                       // Only call the notifier when the item has some content relevant change.
+                       if ($item['origin'] && in_array('edited', array_keys($fields))) {
                                Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);
                        }
                }
@@ -117,12 +118,12 @@ class Item extends BaseObject
                        'verb', 'object-type', 'object', 'target', 'contact-id'];
                $item = dba::selectFirst('item', $fields, ['id' => $item_id]);
                if (!DBM::is_result($item)) {
-                       logger('Item with ID ' . $item_id . " hadn't been found.", LOGGER_DEBUG);
+                       logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
                        return false;
                }
 
                if ($item['deleted']) {
-                       logger('Item with ID ' . $item_id . ' is already deleted.', LOGGER_DEBUG);
+                       logger('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG);
                        return false;
                }
 
@@ -202,7 +203,7 @@ class Item extends BaseObject
                        Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
                }
 
-               logger('Item with ID ' . $item_id . " had been deleted.", LOGGER_DEBUG);
+               logger('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG);
 
                return true;
        }
@@ -344,6 +345,12 @@ class Item extends BaseObject
                        $item['origin'] = 1;
                        $item['network'] = NETWORK_DFRN;
                        $item['protocol'] = PROTOCOL_DFRN;
+
+                       if (is_int($notify)) {
+                               $priority = $notify;
+                       } else {
+                               $priority = PRIORITY_HIGH;
+                       }
                } else {
                        $item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
                }
@@ -872,7 +879,7 @@ class Item extends BaseObject
                check_user_notification($current_post);
 
                if ($notify) {
-                       Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
+                       Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
                } elseif (!empty($parent) && $parent['origin']) {
                        Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", "comment-import", $current_post);
                }