aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Viewsrc.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Viewsrc.php')
-rw-r--r--Zotlabs/Module/Viewsrc.php39
1 files changed, 35 insertions, 4 deletions
diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php
index cfc184a9d..c3d8d96de 100644
--- a/Zotlabs/Module/Viewsrc.php
+++ b/Zotlabs/Module/Viewsrc.php
@@ -1,7 +1,9 @@
<?php
namespace Zotlabs\Module;
-
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\IConfig;
+use Zotlabs\Lib\ObjCache;
class Viewsrc extends \Zotlabs\Web\Controller {
@@ -28,13 +30,16 @@ class Viewsrc extends \Zotlabs\Web\Controller {
$item_normal = item_normal_search();
if(local_channel() && $item_id) {
- $r = q("select id, mid, uuid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
+ $r = q("select * from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
);
if($r) {
+ xchan_query($r, true);
+ $r = fetch_post_tags($r);
+
if(intval($r[0]['item_obscured']))
$dload = true;
@@ -45,9 +50,35 @@ class Viewsrc extends \Zotlabs\Web\Controller {
killme();
}
+ $cached = true;
+
+ $obj = ObjCache::Get($r[0]['mid']);
+
+ if (!$obj) {
+ $obj = IConfig::Get($r[0], 'activitypub', 'rawmsg');
+ }
+
+ if (in_array($r[0]['owner']['xchan_network'], ['diaspora'])) {
+ $obj = ObjCache::Get($r[0]['mid'], 'diaspora');
+
+ if (!$obj) {
+ $obj = IConfig::Get($r[0], 'diaspora', 'fields');
+ }
+ }
+
+ if (!$obj) {
+ $cached = false;
+ $obj = Activity::encode_activity($r[0]);
+ }
+
+ if ($obj) {
+ $content = (($cached) ? 'Cached: ' : '') . '<pre>' . escape_tags(json_encode($obj, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)) . '</pre>';
+ }
+ else {
+ $content = escape_tags($r[0]['body']);
+ }
- $content = escape_tags($r[0]['body']);
- $o = (($json) ? json_encode($content) : $content);
+ $o = (($json) ? json_encode($content) : str_replace("\n", '<br>', $content));
}
}