mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-12-16 02:10:59 +01:00
add plugin hooks invoked when articles get un/marked or un/published
This commit is contained in:
parent
4ae17d0f1c
commit
5f70e41118
@ -284,6 +284,12 @@ class API extends Handler {
|
||||
WHERE ref_id IN ($article_qmarks) AND owner_uid = ?");
|
||||
$sth->execute([...$article_ids, $_SESSION['uid']]);
|
||||
|
||||
if ($field == 'marked')
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, $article_ids);
|
||||
|
||||
if ($field == 'published')
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, $article_ids);
|
||||
|
||||
$num_updated = $sth->rowCount();
|
||||
|
||||
return $this->_wrap(self::STATUS_OK, array("status" => "OK",
|
||||
|
||||
@ -713,4 +713,23 @@ abstract class Plugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Invoked after passed article IDs were either marked (i.e. starred) or unmarked.
|
||||
* **Note** resulting state of the articles is not passed to this function (because
|
||||
* tt-rss may do invert operation on ID range), you will need to get this from the database.
|
||||
* @param array<int> $article_ids ref_ids
|
||||
* @return void
|
||||
*/
|
||||
function hook_articles_marked(array $article_ids) {
|
||||
user_error("Dummy method invoked.", E_USER_ERROR);
|
||||
}
|
||||
|
||||
/** Invoked after passed article IDs were either published or unpublished.
|
||||
* **Note** resulting state of the articles is not passed to this function (because
|
||||
* tt-rss may do invert operation on ID range), you will need to get this from the database.
|
||||
* @param array<int> $article_ids ref_ids
|
||||
* @return void
|
||||
*/
|
||||
function hook_articles_published(array $article_ids) {
|
||||
user_error("Dummy method invoked.", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,6 +199,12 @@ class PluginHost {
|
||||
/** @see Plugin::hook_validate_session() */
|
||||
const HOOK_VALIDATE_SESSION = "hook_validate_session";
|
||||
|
||||
/** @see Plugin::hook_articles_marked() */
|
||||
const HOOK_ARTICLES_MARKED = "hook_articles_marked";
|
||||
|
||||
/** @see Plugin::hook_articles_published() */
|
||||
const HOOK_ARTICLES_PUBLISHED = "hook_articles_published";
|
||||
|
||||
const KIND_ALL = 1;
|
||||
const KIND_SYSTEM = 2;
|
||||
const KIND_USER = 3;
|
||||
|
||||
@ -69,6 +69,8 @@ class RPC extends Handler_Protected {
|
||||
|
||||
$sth->execute([$mark, $id, $_SESSION['uid']]);
|
||||
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, [$id]);
|
||||
|
||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
||||
}
|
||||
|
||||
@ -95,6 +97,8 @@ class RPC extends Handler_Protected {
|
||||
|
||||
$sth->execute([$pub, $id, $_SESSION['uid']]);
|
||||
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$id]);
|
||||
|
||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
||||
}
|
||||
|
||||
@ -345,6 +349,8 @@ class RPC extends Handler_Protected {
|
||||
}
|
||||
|
||||
$sth->execute([...$ids, $_SESSION['uid']]);
|
||||
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,6 +375,8 @@ class RPC extends Handler_Protected {
|
||||
}
|
||||
|
||||
$sth->execute([...$ids, $_SESSION['uid']]);
|
||||
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, $ids);
|
||||
}
|
||||
|
||||
function log(): void {
|
||||
|
||||
@ -1132,6 +1132,12 @@ class RSSUtils {
|
||||
$sth->execute([$ref_id, $feed_obj->owner_uid, $feed, $unread, $last_read_qpart, $marked,
|
||||
$published, $score]);
|
||||
|
||||
if ($marked)
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, [$ref_id]);
|
||||
|
||||
if ($published)
|
||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$ref_id]);
|
||||
|
||||
$sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE
|
||||
ref_id = ? AND owner_uid = ? AND
|
||||
feed_id = ? LIMIT 1");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user