- $notification = DI::notify()->insert([
- 'name' => $params['source_name'] ?? '',
- 'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'] ?? '')), 0, 255),
- 'url' => $params['source_link'] ?? '',
- 'photo' => $params['source_photo'] ?? '',
- 'link' => $itemlink ?? '',
- 'uid' => $params['uid'] ?? 0,
- 'iid' => $item_id ?? 0,
- 'parent' => $parent_id ?? 0,
- 'type' => $params['type'] ?? '',
- 'verb' => $params['verb'] ?? '',
- 'otype' => $params['otype'] ?? '',
- ]);
+ $fields = [
+ 'name' => $params['source_name'] ?? '',
+ 'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'])), 0, 255),
+ 'url' => $params['source_link'] ?? '',
+ 'photo' => $params['source_photo'] ?? '',
+ 'link' => $itemlink ?? '',
+ 'uid' => $params['uid'] ?? 0,
+ 'type' => $params['type'] ?? '',
+ 'verb' => $params['verb'] ?? '',
+ 'otype' => $params['otype'] ?? '',
+ ];
+ if (!empty($item_id)) {
+ $fields['iid'] = $item_id;
+ }
+ if (!empty($uri_id)) {
+ $fields['uri-id'] = $uri_id;
+ }
+ if (!empty($parent_id)) {
+ $fields['parent'] = $parent_id;
+ }
+ if (!empty($parent_uri_id)) {
+ $fields['parent-uri-id'] = $parent_uri_id;
+ }
+ $notification = DI::notify()->insert($fields);
+
+ // Notification insertion can be intercepted by an addon registering the 'enotify_store' hook
+ if (!$notification) {
+ return false;
+ }