aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-09-15 10:59:16 +0000
committerMario <mario@mariovavti.com>2021-09-15 10:59:16 +0000
commit46b8db53ab021be06f6dd9c15e6b69c22609aa0f (patch)
tree8d4de70028a74e17068f4451a67e4d8a17c7b30c /Zotlabs
parent0b716b3cc7953ef1226b9f8fcee9f746ee1aade1 (diff)
downloadvolse-hubzilla-46b8db53ab021be06f6dd9c15e6b69c22609aa0f.tar.gz
volse-hubzilla-46b8db53ab021be06f6dd9c15e6b69c22609aa0f.tar.bz2
volse-hubzilla-46b8db53ab021be06f6dd9c15e6b69c22609aa0f.zip
provide a get_cached_actor_provider hook and improve the author/owner handling in Libzot::import()
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Activity.php16
-rw-r--r--Zotlabs/Lib/Libzot.php36
2 files changed, 38 insertions, 14 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 62a22f70e..a0a9a7c7f 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -3548,7 +3548,21 @@ class Activity {
}
static function get_cached_actor($id) {
- return (XConfig::Get($id,'system','actor_record'));
+ $actor = XConfig::Get($id,'system', 'actor_record');
+
+ if ($actor) {
+ return $actor;
+ }
+
+ // try other get_cached_actor providers (e.g. diaspora)
+ $hookdata = [
+ 'id' => $id,
+ 'actor' => false
+ ];
+
+ call_hooks('get_cached_actor_provider', $hookdata);
+
+ return $hookdata['actor'];
}
static function get_actor_hublocs($url, $options = 'all') {
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 343a3f5f9..f3cf52a33 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1200,31 +1200,41 @@ class Libzot {
if (in_array($env['type'], ['activity', 'response'])) {
- $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' ",
+ if(!isset($AS->actor['id'])) {
+ logger('No actor id!');
+ return;
+ }
+
+ $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'",
dbesc($AS->actor['id'])
);
if ($r) {
- // selects a zot6 hash if available, otherwise use whatever we have
- $r = self::zot_record_preferred($r);
+ $r = self::zot_record_preferred($r);
$arr['author_xchan'] = $r['hubloc_hash'];
}
- if (!$arr['author_xchan']) {
+ if (! $arr['author_xchan']) {
logger('No author!');
return;
}
- $s = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
- dbesc($env['sender'])
- );
+ $arr['owner_xchan'] = $env['sender'];
- // in individual delivery, change owner if needed
- if ($s) {
- $arr['owner_xchan'] = $s[0]['hubloc_hash'];
+ if(filter_var($env['sender'], FILTER_VALIDATE_URL))
+ // in individual delivery, change owner if needed
+ $s = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
+ dbesc($env['sender'])
+ );
+
+ if ($s) {
+ $arr['owner_xchan'] = $s[0]['hubloc_hash'];
+ }
}
- else {
- $arr['owner_xchan'] = $env['sender'];
+
+ if (! $arr['owner_xchan']) {
+ logger('No owner!');
+ return;
}
if ($private && (!intval($arr['item_private']))) {
@@ -1714,7 +1724,7 @@ class Libzot {
}
}
- $ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'",
+ $ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'",
intval($channel['channel_id']),
dbesc($arr['owner_xchan'])
);