Fix missing notifications:

- Add namecache in enotify
- Add "unset()" in notify repository for additional field "abort"
- Add possibility for additional, non-saved fields in model
This commit is contained in:
Philipp Holzer 2020-01-28 01:02:53 +01:00
parent 977248f510
commit 443e106105
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 44 additions and 2 deletions

View 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'],

View 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()

View 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,
];
}
}

View 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);