mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:55:18 +00:00
Trying to make practical use of lame specs continued.
This commit is contained in:
parent
e391a29cda
commit
cf551b674a
5 changed files with 37 additions and 22 deletions
|
@ -2440,6 +2440,7 @@ class Activity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$actorIdUrl = $url;
|
||||||
$actorId = new ActorId($url);
|
$actorId = new ActorId($url);
|
||||||
$url = $actorId->getId();
|
$url = $actorId->getId();
|
||||||
$isDid = in_array($actorId->getType(), [ActorId::ACTORID_TYPE_DIDKEY, ActorId::ACTORID_TYPE_DIDWEB]);
|
$isDid = in_array($actorId->getType(), [ActorId::ACTORID_TYPE_DIDKEY, ActorId::ACTORID_TYPE_DIDWEB]);
|
||||||
|
@ -2621,7 +2622,7 @@ class Activity
|
||||||
// create a new record
|
// create a new record
|
||||||
xchan_store_lowlevel( [
|
xchan_store_lowlevel( [
|
||||||
'xchan_hash' => $url,
|
'xchan_hash' => $url,
|
||||||
'xchan_guid' => $url,
|
'xchan_guid' => $actorIdUrl,
|
||||||
'xchan_pubkey' => $pubkey,
|
'xchan_pubkey' => $pubkey,
|
||||||
'xchan_epubkey' => $epubkey,
|
'xchan_epubkey' => $epubkey,
|
||||||
'xchan_addr' => $webfingerAddress,
|
'xchan_addr' => $webfingerAddress,
|
||||||
|
|
|
@ -264,13 +264,15 @@ class ActivityPub
|
||||||
$orig_follow_type = get_abconfig($x['sender']['channel_id'], $x['recipient']['xchan_hash'], 'activitypub', 'their_follow_type');
|
$orig_follow_type = get_abconfig($x['sender']['channel_id'], $x['recipient']['xchan_hash'], 'activitypub', 'their_follow_type');
|
||||||
|
|
||||||
$locations = Activity::get_actor_hublocs($x['recipient']['xchan_hash'], 'activitypub, not_deleted');
|
$locations = Activity::get_actor_hublocs($x['recipient']['xchan_hash'], 'activitypub, not_deleted');
|
||||||
|
$isNomadic = PConfig::Get($x['sender']['channel_id'], 'system', 'nomadicAP');
|
||||||
|
$rootPath = (($isNomadic) ? Channel::getDidResolver($x['sender']) : z_root());
|
||||||
|
|
||||||
if ($locations) {
|
if ($locations) {
|
||||||
foreach ($locations as $location) {
|
foreach ($locations as $location) {
|
||||||
$msg = array_merge(
|
$msg = array_merge(
|
||||||
Activity::ap_context(),
|
Activity::ap_context(),
|
||||||
[
|
[
|
||||||
'id' => z_root() . '/follow/' . $x['recipient']['abook_id'] . (($orig_follow) ? '/' . md5($orig_follow) : EMPTY_STR),
|
'id' => $rootPath . '/follow/' . $x['recipient']['abook_id'] . (($orig_follow) ? '/' . md5($orig_follow) : EMPTY_STR),
|
||||||
'type' => (($orig_follow_type) ?: 'Follow'),
|
'type' => (($orig_follow_type) ?: 'Follow'),
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => $location['hubloc_id_url'],
|
'object' => $location['hubloc_id_url'],
|
||||||
|
@ -339,20 +341,21 @@ class ActivityPub
|
||||||
if (!$p) {
|
if (!$p) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$isNomadic = PConfig::Get($x['sender']['channel_id'], 'system', 'nomadicAP');
|
||||||
|
$rootPath = (($isNomadic) ? Channel::getDidResolver($x['sender']) : z_root());
|
||||||
$msg = array_merge(
|
$msg = array_merge(
|
||||||
Activity::ap_context(),
|
Activity::ap_context(),
|
||||||
[
|
[
|
||||||
'id' => z_root() . '/follow/' . $x['recipient']['abook_id'] . '/' . md5($accept),
|
'id' => $rootPath . '/follow/' . $x['recipient']['abook_id'] . '/' . md5($accept),
|
||||||
'type' => 'Accept',
|
'type' => 'Accept',
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => [
|
'object' => [
|
||||||
'type' => (($follow_type) ?: 'Follow'),
|
'type' => (($follow_type) ?: 'Follow'),
|
||||||
'id' => $accept,
|
'id' => $accept,
|
||||||
'actor' => $x['recipient']['xchan_hash'],
|
'actor' => $x['recipient']['xchan_guid'],
|
||||||
'object' => Channel::getDidResolver($x['sender'], true)
|
'object' => Channel::getDidResolver($x['sender'], true)
|
||||||
],
|
],
|
||||||
'to' => [$x['recipient']['xchan_hash']],
|
'to' => [$x['recipient']['xchan_guid']],
|
||||||
'cc' => []
|
'cc' => []
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -384,15 +387,17 @@ class ActivityPub
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isNomadic = PConfig::Get($x['sender']['channel_id'], 'system', 'nomadicAP');
|
||||||
|
|
||||||
$msg = array_merge(
|
$msg = array_merge(
|
||||||
Activity::ap_context(),
|
Activity::ap_context(),
|
||||||
[
|
[
|
||||||
'id' => z_root() . '/channel/' . $x['sender']['channel_address'] . '#update',
|
'id' => Channel::getDidResolver($x['sender'], true) . '#update',
|
||||||
'type' => 'Update',
|
'type' => 'Update',
|
||||||
'updated' => Time::convert(format: ISO8601),
|
'updated' => Time::convert(format: ISO8601),
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => z_root() . '/channel/' . $x['sender']['channel_address'],
|
'object' => Channel::getDidResolver($x['sender'], true),
|
||||||
'to' => [z_root() . '/followers/' . $x['sender']['channel_address']],
|
'to' => [($isNomadic) ? Channel::getDidResolver($x['sender']) . 'actor/followers' : z_root() . '/followers/' . $x['sender']['channel_address']],
|
||||||
'cc' => [ACTIVITY_PUBLIC_INBOX]
|
'cc' => [ACTIVITY_PUBLIC_INBOX]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -439,6 +444,9 @@ class ActivityPub
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isNomadic = PConfig::Get($channel['channel_id'], 'system', 'nomadicAP');
|
||||||
|
$rootPath = (($isNomadic) ? Channel::getDidResolver($channel) : z_root());
|
||||||
|
|
||||||
// send an unfollow activity to the followee's inbox
|
// send an unfollow activity to the followee's inbox
|
||||||
|
|
||||||
$orig_activity = get_abconfig($recip[0]['abook_channel'], $recip[0]['xchan_hash'], 'activitypub', 'follow_id');
|
$orig_activity = get_abconfig($recip[0]['abook_channel'], $recip[0]['xchan_hash'], 'activitypub', 'follow_id');
|
||||||
|
@ -446,19 +454,20 @@ class ActivityPub
|
||||||
if ($orig_activity && $recip[0]['abook_pending']) {
|
if ($orig_activity && $recip[0]['abook_pending']) {
|
||||||
// was never approved
|
// was never approved
|
||||||
|
|
||||||
|
|
||||||
$msg = array_merge(
|
$msg = array_merge(
|
||||||
Activity::ap_context(),
|
Activity::ap_context(),
|
||||||
[
|
[
|
||||||
'id' => z_root() . '/follow/' . $recip[0]['abook_id'] . '/' . md5($orig_activity) . '?operation=reject',
|
'id' => $rootPath . '/follow/' . $recip[0]['abook_id'] . '/' . md5($orig_activity) . '?operation=reject',
|
||||||
'type' => 'Reject',
|
'type' => 'Reject',
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => [
|
'object' => [
|
||||||
'type' => 'Follow',
|
'type' => 'Follow',
|
||||||
'id' => $orig_activity,
|
'id' => $orig_activity,
|
||||||
'actor' => $recip[0]['xchan_hash'],
|
'actor' => $recip[0]['xchan_guid'],
|
||||||
'object' => $p
|
'object' => $p
|
||||||
],
|
],
|
||||||
'to' => [$recip[0]['xchan_hash']],
|
'to' => [$recip[0]['xchan_guid']],
|
||||||
'cc' => []
|
'cc' => []
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -469,16 +478,16 @@ class ActivityPub
|
||||||
$msg = array_merge(
|
$msg = array_merge(
|
||||||
Activity::ap_context(),
|
Activity::ap_context(),
|
||||||
[
|
[
|
||||||
'id' => z_root() . '/follow/' . $recip[0]['abook_id'] . (($orig_activity) ? '/' . md5($orig_activity) : EMPTY_STR) . '?operation=unfollow',
|
'id' => $rootPath . '/follow/' . $recip[0]['abook_id'] . (($orig_activity) ? '/' . md5($orig_activity) : EMPTY_STR) . '?operation=unfollow',
|
||||||
'type' => 'Undo',
|
'type' => 'Undo',
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => [
|
'object' => [
|
||||||
'id' => z_root() . '/follow/' . $recip[0]['abook_id'] . (($orig_activity) ? '/' . md5($orig_activity) : EMPTY_STR),
|
'id' => $rootPath . '/follow/' . $recip[0]['abook_id'] . (($orig_activity) ? '/' . md5($orig_activity) : EMPTY_STR),
|
||||||
'type' => 'Follow',
|
'type' => 'Follow',
|
||||||
'actor' => $p,
|
'actor' => $p,
|
||||||
'object' => $recip[0]['xchan_hash']
|
'object' => $recip[0]['xchan_guid']
|
||||||
],
|
],
|
||||||
'to' => [$recip[0]['xchan_hash']],
|
'to' => [$recip[0]['xchan_guid']],
|
||||||
'cc' => []
|
'cc' => []
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -2080,10 +2080,13 @@ class Channel
|
||||||
return self::getDid($channel);
|
return self::getDid($channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getVerifier($channel)
|
public static function getVerifier($channel, $id = '')
|
||||||
{
|
{
|
||||||
$pubkey = (new Multibase())->publicKey($channel['channel_epubkey']);
|
$pubkey = (new Multibase())->publicKey($channel['channel_epubkey']);
|
||||||
$nomadic = PConfig::Get($channel['channel_id'], 'system', 'nomadicAP');
|
$nomadic = PConfig::Get($channel['channel_id'], 'system', 'nomadicAP');
|
||||||
|
if (!str_contains($id, '/.well-known/apgateway/')) {
|
||||||
|
$nomadic = false;
|
||||||
|
}
|
||||||
return (($nomadic) ? Channel::getDid($channel) : Channel::url($channel) . '#' . $pubkey);
|
return (($nomadic) ? Channel::getDid($channel) : Channel::url($channel) . '#' . $pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class JcsEddsa2022
|
||||||
'type' => 'DataIntegrityProof',
|
'type' => 'DataIntegrityProof',
|
||||||
'cryptosuite' => 'eddsa-jcs-2022',
|
'cryptosuite' => 'eddsa-jcs-2022',
|
||||||
'created' => Time::convert(format: ISO8601),
|
'created' => Time::convert(format: ISO8601),
|
||||||
'verificationMethod' => Channel::getVerifier($channel),
|
'verificationMethod' => Channel::getVerifier($channel, $data['id'] ?? ''),
|
||||||
'proofPurpose' => 'assertionMethod',
|
'proofPurpose' => 'assertionMethod',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Code\Module;
|
namespace Code\Module;
|
||||||
|
|
||||||
use App;
|
use App;
|
||||||
|
use Code\Lib\PConfig;
|
||||||
use Code\Web\Controller;
|
use Code\Web\Controller;
|
||||||
use Code\Lib\Libsync;
|
use Code\Lib\Libsync;
|
||||||
use Code\Lib\ActivityStreams;
|
use Code\Lib\ActivityStreams;
|
||||||
|
@ -48,12 +49,13 @@ class Follow extends Controller
|
||||||
|
|
||||||
$orig_follow = get_abconfig($chan['channel_id'], $r[0]['xchan_hash'], 'activitypub', 'their_follow_id');
|
$orig_follow = get_abconfig($chan['channel_id'], $r[0]['xchan_hash'], 'activitypub', 'their_follow_id');
|
||||||
$orig_follow_type = get_abconfig($chan['channel_id'], $r[0]['xchan_hash'], 'activitypub', 'their_follow_type');
|
$orig_follow_type = get_abconfig($chan['channel_id'], $r[0]['xchan_hash'], 'activitypub', 'their_follow_type');
|
||||||
|
$isNomadic = PConfig::Get($chan['channel_id'], 'system', 'nomadicAP');
|
||||||
|
$rootPath = (($isNomadic) ? Channel::getDidResolver($chan) : z_root());
|
||||||
as_return_and_die([
|
as_return_and_die([
|
||||||
'id' => z_root() . '/follow/' . $r[0]['abook_id'] . (($orig_follow) ? '/' . md5($orig_follow) : EMPTY_STR),
|
'id' => $rootPath . '/follow/' . $r[0]['abook_id'] . (($orig_follow) ? '/' . md5($orig_follow) : EMPTY_STR),
|
||||||
'type' => (($orig_follow_type) ?: 'Follow'),
|
'type' => (($orig_follow_type) ?: 'Follow'),
|
||||||
'actor' => $actor,
|
'actor' => $actor,
|
||||||
'object' => $r[0]['xchan_url']
|
'object' => $r[0]['xchan_guid']
|
||||||
], $chan);
|
], $chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ class Follow extends Controller
|
||||||
info(t('Connection added.') . EOL);
|
info(t('Connection added.') . EOL);
|
||||||
Channel::abook_sync($channel, $result['abook']);
|
Channel::abook_sync($channel, $result['abook']);
|
||||||
|
|
||||||
$can_view_stream = their_perms_contains($channel['channel_id'], $clone['abook_xchan'], 'view_stream');
|
$can_view_stream = their_perms_contains($channel['channel_id'], $result['abook']['abook_xchan'], 'view_stream');
|
||||||
|
|
||||||
// If we can view their stream, pull in some posts
|
// If we can view their stream, pull in some posts
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue