]> git.mxchange.org Git - friendica.git/commitdiff
Fix missing notifications:
authornupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 00:02:53 +0000 (01:02 +0100)
committernupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 17:41:45 +0000 (18:41 +0100)
- Add namecache in enotify
- Add "unset()" in notify repository for additional field "abort"
- Add possibility for additional, non-saved fields in model

include/enotify.php
src/BaseModel.php
src/Model/Notify.php
src/Repository/Notify.php

index 3332f4a082ec75605e5888b4a201543393700f48..b35d5507cc90c0e0cf39eec4e8946098d73f8f24 100644 (file)
@@ -484,6 +484,7 @@ function notification($params)
        if ($show_in_notification_page) {
                $notification = DI::notify()->insert([
                        'name'   => $params['source_name'],
+                       'name_cache' => strip_tags(BBCode::convert($params['source_name'])),
                        'url'    => $params['source_link'],
                        'photo'  => $params['source_photo'],
                        'uid'    => $params['uid'],
index 4e4259170872ea23977c24ef7a425f52b4675575..791d6887c1702d088308bed27a4870b9c1766e0b 100644 (file)
@@ -48,9 +48,23 @@ abstract class BaseModel
                $this->originalData = $data;
        }
 
+       /**
+        * Maps a data array (original/current) to a known field list of the chosen model
+        *
+        * This is useful to filter out additional attributes, which aren't part of the db-table (like readonly cached fields)
+        *
+        * @param array $data The data array to map to db-fields
+        *
+        * @return array the mapped data array
+        */
+       protected function mapFields(array $data)
+       {
+               return $data;
+       }
+
        public function getOriginalData()
        {
-               return $this->originalData;
+               return $this->mapFields($this->originalData);
        }
 
        public function resetOriginalData()
@@ -117,7 +131,7 @@ abstract class BaseModel
 
        public function toArray()
        {
-               return $this->data;
+               return $this->mapFields($this->data);
        }
 
        protected function checkValid()
index 1bb9f29047a701d0297fea225b4fbcf4efa261de..c48fa0f679051af1506e25bc90ddadc3a05ead02 100644 (file)
@@ -163,4 +163,29 @@ class Notify extends BaseModel
 
                return $message;
        }
+
+       /**
+        * {@inheritDoc}
+        */
+       protected function mapFields(array $data)
+       {
+               return [
+                       'hash'       => $data['hash'] ?? '',
+                       'type'       => $data['type'] ?? 0,
+                       'name'       => $data['name'] ?? '',
+                       'url'        => $data['url'] ?? '',
+                       'photo'      => $data['photo'] ?? '',
+                       'date'       => $data['date'] ?? DateTimeFormat::utcNow(),
+                       'msg'        => $data['msg'] ?? '',
+                       'uid'        => $data['uid'] ?? 0,
+                       'link'       => $data['link'] ?? '',
+                       'iid'        => $data['iid'] ?? 0,
+                       'parent'     => $data['parent'] ?? 0,
+                       'seen'       => $data['seen'] ?? false,
+                       'verb'       => $data['verb'] ?? '',
+                       'otype'      => $data['otype'] ?? '',
+                       'name_cache' => $data['name_cache'] ?? null,
+                       'msg_cache'  => $data['msg_cache'] ?? null,
+               ];
+       }
 }
index 2ac14858f58adb16f0edf0dac47accb5307740f1..5f2d9f8a7fa5bc344fc6d50d11b848dd22b713ce 100644 (file)
@@ -84,6 +84,8 @@ class Notify extends BaseRepository
                        return null;
                }
 
+               unset($fields['abort']);
+
                $this->logger->debug('adding notification entry', ['fields' => $fields]);
 
                return parent::insert($fields);