]> git.mxchange.org Git - friendica.git/commitdiff
Functionality is now added
authorMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 01:23:40 +0000 (01:23 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 01:23:40 +0000 (01:23 +0000)
src/Model/Item.php
src/Model/UserItem.php

index c9d71e8c1e696eda410fec2c46628c5a35bca119..e030141fa87fe25179ab39de2e25d60c1b5224e0 100644 (file)
@@ -2026,6 +2026,8 @@ class Item
 
                self::updateContact($item);
 
+               UserItem::setNotification($current_post, $item['uid']);
+
                check_user_notification($current_post);
 
                if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) {
index ea61696e390fe606a5861f41c6f89fbec2ffcbd9..d0d1ebad9898ed1777d88c6c1ab1a7b6b575cf96 100644 (file)
@@ -6,6 +6,7 @@
 
 namespace Friendica\Model;
 
+use Friendica\Core\Logger;
 use Friendica\Core\Hook;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -28,8 +29,12 @@ class UserItem
         * @param array $item The message array that is checked for notifications
         * @param int   $uid  User ID
         */
-       public static function setNotification($item, $uid)
+       public static function setNotification($iid, $uid)
        {
+               $fields = ['id', 'body', 'origin', 'parent', 'gravity', 'tag', 'contact-id',
+                       'thr-parent', 'parent-uri', 'mention'];
+               $item = Item::selectFirst($fields, ['id' => $iid]);
+
                // Don't check for own posts
                if ($item['origin'] || empty($uid)) {
                        return;
@@ -80,6 +85,12 @@ class UserItem
                        $notification_type = $notification_type | self::NOTIF_ACTIVITY_PARTICIPATION;
                }
 
+               if (empty($notification_type)) {
+                       return;
+               }
+
+               Logger::info('Set notification', ['iid' => $item['id'], 'uid' => $uid, 'notification-type' => $notification_type]);
+
                DBA::update('user-item', ['notification-type' => $notification_type], ['iid' => $item['id'], 'uid' => $uid], true);
        }
 
@@ -144,7 +155,7 @@ class UserItem
                }
 
                // Or the contact is a mentioned forum
-               $tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => TERM_MENTION, 'uid' => $uid]);
+               $tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $item['id'], 'type' => TERM_MENTION, 'uid' => $uid]);
                while ($tag = DBA::fetch($tags)) {
                        $condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
                        if (DBA::exists('contact', $condition)) {