aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-02-15 13:33:23 +0000
committerMario <mario@mariovavti.com>2023-02-15 13:33:23 +0000
commit09a60774d746de57d6f9e479a1f6cf70c691f031 (patch)
tree1c93fee3a5a88b4cbcd9d9b9237451cf2fee99a1
parent1ca988b177834467671137c94f17a5948b465f6f (diff)
downloadvolse-hubzilla-09a60774d746de57d6f9e479a1f6cf70c691f031.tar.gz
volse-hubzilla-09a60774d746de57d6f9e479a1f6cf70c691f031.tar.bz2
volse-hubzilla-09a60774d746de57d6f9e479a1f6cf70c691f031.zip
we can sign messages which are not from the primary location
-rw-r--r--Zotlabs/Lib/Libzot.php7
-rw-r--r--include/channel.php2
-rw-r--r--include/hubloc.php8
-rw-r--r--include/text.php4
4 files changed, 14 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 5610a21b2..8b4662bee 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -101,7 +101,6 @@ class Libzot {
static function build_packet($channel, $type = 'activity', $recipients = null, $msg = [], $encoding = 'activitystreams', $remote_key = null, $methods = '') {
$sig_method = get_config('system', 'signature_algorithm', 'sha256');
-
$data = [
'type' => $type,
'encoding' => $encoding,
@@ -115,9 +114,9 @@ class Libzot {
}
if ($msg) {
- $actor = channel_url($channel);
- if ($encoding === 'activitystreams' && array_key_exists('actor', $msg) && is_string($msg['actor']) && $actor === $msg['actor']) {
- $msg = JSalmon::sign($msg, $actor, $channel['channel_prvkey']);
+ $actors = get_hubloc_id_urls_by_x($channel['channel_hash']);
+ if ($encoding === 'activitystreams' && array_key_exists('actor', $msg) && is_string($msg['actor']) && in_array($msg['actor'], $actors)) {
+ $msg = JSalmon::sign($msg, $actors[0], $channel['channel_prvkey']);
}
$data['data'] = $msg;
}
diff --git a/include/channel.php b/include/channel.php
index 296615524..c36e50f19 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -3086,6 +3086,6 @@ function channel_url($channel) {
}
function get_channel_hashes() {
- $r = q("SELECT channel_hash FROM channel WHERE channel_removed = 0");
+ $r = dbq("SELECT channel_hash FROM channel WHERE channel_removed = 0");
return flatten_array_recursive($r);
}
diff --git a/include/hubloc.php b/include/hubloc.php
index 0236e4ae7..4d2980a6b 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -392,3 +392,11 @@ function z6_discover() {
}
}
+
+function get_hubloc_id_urls_by_x($xchan) {
+ $r = q("SELECT hubloc_id_url FROM hubloc WHERE hubloc_deleted = 0 AND hubloc_hash = '%s' order by hubloc_primary desc",
+ dbesc($xchan)
+ );
+ return flatten_array_recursive($r);
+}
+
diff --git a/include/text.php b/include/text.php
index 35ce465d6..a09d1bd7b 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2621,13 +2621,13 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0) {
if(count($arr)) {
if($abook) {
$chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d
- where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1",
+ where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc",
intval($item['uid'])
);
}
else {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1");
+ where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc");
}
$xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown', 'anon', 'token')");
if(! $chans)