summaryrefslogtreecommitdiff
path: root/classes/api.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-15 09:40:43 +0300
committerAndrew Dolgov <[email protected]>2021-02-15 09:40:43 +0300
commit868b9b476e3d534672bb7deb940eea2059b90494 (patch)
tree25b2c2bd8caddd334588fa8b88b9b33313e9a6f8 /classes/api.php
parent52a86c5e387689860ae345ee5f1cb3dcf1a974ee (diff)
api: rewrite article urls at the very end to prevent plugins which expect source URLs from breaking
Diffstat (limited to 'classes/api.php')
-rwxr-xr-xclasses/api.php32
1 files changed, 18 insertions, 14 deletions
diff --git a/classes/api.php b/classes/api.php
index 9299c34ea..6debad2f7 100755
--- a/classes/api.php
+++ b/classes/api.php
@@ -754,8 +754,6 @@ class API extends Handler {
} else {
$headline_row["content"] = $line["content"];
}
-
- $headline_row["content"] = DiskCache::rewriteUrls($headline_row['content']);
}
// unify label output to ease parsing
@@ -776,22 +774,28 @@ class API extends Handler {
$headline_row["note"] = $line["note"];
$headline_row["lang"] = $line["lang"];
- $hook_object = ["headline" => &$headline_row];
+ if ($show_content) {
+ $hook_object = ["headline" => &$headline_row];
- PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_API,
- function ($result) use (&$headline_row) {
- $headline_row = $result;
- },
- $hook_object);
+ list ($flavor_image, $flavor_stream, $flavor_kind) = Article::get_article_image($enclosures,
+ $line["content"], // unsanitized
+ $line["site_url"]);
- list ($flavor_image, $flavor_stream, $flavor_kind) = Article::get_article_image($enclosures, $line["content"], $line["site_url"]);
+ $headline_row["flavor_image"] = $flavor_image;
+ $headline_row["flavor_stream"] = $flavor_stream;
- $headline_row["flavor_image"] = $flavor_image;
- $headline_row["flavor_stream"] = $flavor_stream;
+ /* optional */
+ if ($flavor_kind)
+ $headline_row["flavor_kind"] = $flavor_kind;
- /* optional */
- if ($flavor_kind)
- $headline_row["flavor_kind"] = $flavor_kind;
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_API,
+ function ($result) use (&$headline_row) {
+ $headline_row = $result;
+ },
+ $hook_object);
+
+ $headline_row["content"] = DiskCache::rewriteUrls($headline_row['content']);
+ }
array_push($headlines, $headline_row);
}