aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/ActivityStreams.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-01-27 16:36:26 +0000
committerMario <mario@mariovavti.com>2024-01-27 16:36:26 +0000
commit5e780ba089aa8493eb5bec30558345b070ef808c (patch)
treeb206fac1263c23fccf6311056f88763f5dc6aed7 /Zotlabs/Lib/ActivityStreams.php
parentc0a7dfe2f6554fc66e753c456551dd580c479820 (diff)
downloadvolse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.tar.gz
volse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.tar.bz2
volse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.zip
implement short time object cache to reduce network calls and some cleanup
Diffstat (limited to 'Zotlabs/Lib/ActivityStreams.php')
-rw-r--r--Zotlabs/Lib/ActivityStreams.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index 0770f2040..3749126d3 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -90,6 +90,15 @@ class ActivityStreams {
// Attempt to assemble an Activity from what we were given.
if ($this->is_valid()) {
$this->id = $this->get_property_obj('id');
+
+ if (!$this->id) {
+ logger('Data with mmissing id: ' . print_r($this->data, true));
+ return;
+ }
+
+ // cache for future use
+ ASCache::Set($this->id, 'json:' . $this->raw);
+
$this->type = $this->get_primary_type();
$this->actor = $this->get_actor('actor', '', '');
$this->obj = $this->get_compound_property('object');
@@ -394,12 +403,22 @@ class ActivityStreams {
$x = $this->get_property_obj($property, $base, $namespace);
if ($this->is_url($x)) {
- $y = $this->fetch_property($x);
+ $cached = ASCache::Get($x);
+ if ($cached) {
+ $y = unserialise($cached);
+ }
+ else {
+ $y = $this->fetch_property($x);
+ if ($y) {
+ ASCache::Set($x, serialise($y));
+ }
+ }
if (is_array($y)) {
$x = $y;
}
}
+
// verify and unpack JSalmon signature if present
if (is_array($x) && array_key_exists('signed', $x)) {