summaryrefslogtreecommitdiff
path: root/app/Controllers/importExportController.php
diff options
context:
space:
mode:
authorGravatar KleinMann <47398070+rnkln@users.noreply.github.com> 2025-09-18 23:44:17 +0200
committerGravatar GitHub <noreply@github.com> 2025-09-18 23:44:17 +0200
commitd670bf1e72d92c3bbeeca874f6a042f4e3a74007 (patch)
tree4510716c59ef202f2b5746b7cc1968ee1c810944 /app/Controllers/importExportController.php
parent055342118fd26d85b4be045f582fd1b8568bf6e4 (diff)
Add `entry_before_update` and `entry_before_add` hooks (#7977)
Discussion: https://github.com/FreshRSS/FreshRSS/discussions/7973 Changes proposed in this pull request: - Add new extension hook "entry_before_add" - Add new extension hook "entry_before_update" How to test the feature manually: 1. Create extension that uses the hooks and confirm they are invoked correctly. Extension to use for testing https://github.com/rnkln/freshrss-xExtension-Discord/pull/2
Diffstat (limited to 'app/Controllers/importExportController.php')
-rw-r--r--app/Controllers/importExportController.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 6ecd9b501..9f9f6b2bd 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -485,9 +485,22 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
}
if (isset($existingHashForGuids['f_' . $feed_id][$entry->guid()])) {
+ $entry = Minz_ExtensionManager::callHook('entry_before_update', $entry);
+ if (!($entry instanceof FreshRSS_Entry)) {
+ // An extension has returned a null value, there is nothing to insert.
+ continue;
+ }
+
$ok = $this->entryDAO->updateEntry($entry->toArray());
} else {
$entry->_lastSeen(time());
+
+ $entry = Minz_ExtensionManager::callHook('entry_before_add', $entry);
+ if (!($entry instanceof FreshRSS_Entry)) {
+ // An extension has returned a null value, there is nothing to insert.
+ continue;
+ }
+
$ok = $this->entryDAO->addEntry($entry->toArray());
}