mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:55:13 +00:00
Merge branch 'dev' of codeberg.org:streams/streams into dev
This commit is contained in:
commit
c8bddf3eaf
9 changed files with 54 additions and 52 deletions
|
@ -4790,7 +4790,7 @@ function list_attached_local_files($body) {
|
|||
function fix_attached_permissions($uid,$body,$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny,$token = EMPTY_STR) {
|
||||
|
||||
$channel = Channel::from_id($uid);
|
||||
|
||||
|
||||
$files = list_attached_local_files($body);
|
||||
if (! $files) {
|
||||
return;
|
||||
|
|
|
@ -2739,35 +2739,11 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0)
|
|||
}
|
||||
}
|
||||
|
||||
function xchan_mail_query(&$item)
|
||||
{
|
||||
$arr = [];
|
||||
$chans = null;
|
||||
if ($item) {
|
||||
if ($item['from_xchan'] && (! in_array("'" . dbesc($item['from_xchan']) . "'", $arr))) {
|
||||
$arr[] = "'" . dbesc($item['from_xchan']) . "'";
|
||||
}
|
||||
if ($item['to_xchan'] && (! in_array("'" . dbesc($item['to_xchan']) . "'", $arr))) {
|
||||
$arr[] = "'" . dbesc($item['to_xchan']) . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($arr)) {
|
||||
$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 and hubloc_deleted = 0");
|
||||
}
|
||||
if ($chans) {
|
||||
$item['from'] = find_xchan_in_array($item['from_xchan'], $chans);
|
||||
$item['to'] = find_xchan_in_array($item['to_xchan'], $chans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function find_xchan_in_array($xchan, $arr)
|
||||
{
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $x) {
|
||||
if ($x['xchan_hash'] === $xchan) {
|
||||
if (strtolower($x['xchan_hash']) === strtolower($xchan)) {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,7 @@ class Poller implements DaemonInterface
|
|||
}
|
||||
}
|
||||
|
||||
$interval = intval(get_config('system', 'poll_interval'));
|
||||
if (! $interval) {
|
||||
$interval = ((get_config('system', 'delivery_interval') === false) ? 3 : intval(get_config('system', 'delivery_interval')));
|
||||
}
|
||||
$interval = intval(get_config('system', 'poll_interval', 3));
|
||||
|
||||
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
|
||||
$lockfile = 'cache/poller';
|
||||
|
|
|
@ -2440,6 +2440,7 @@ class Activity
|
|||
return;
|
||||
}
|
||||
|
||||
$actorIdUrl = $url;
|
||||
$actorId = new ActorId($url);
|
||||
$url = $actorId->getId();
|
||||
$isDid = in_array($actorId->getType(), [ActorId::ACTORID_TYPE_DIDKEY, ActorId::ACTORID_TYPE_DIDWEB]);
|
||||
|
@ -2621,7 +2622,7 @@ class Activity
|
|||
// create a new record
|
||||
xchan_store_lowlevel( [
|
||||
'xchan_hash' => $url,
|
||||
'xchan_guid' => $url,
|
||||
'xchan_guid' => $actorIdUrl,
|
||||
'xchan_pubkey' => $pubkey,
|
||||
'xchan_epubkey' => $epubkey,
|
||||
'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');
|
||||
|
||||
$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) {
|
||||
foreach ($locations as $location) {
|
||||
$msg = array_merge(
|
||||
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'),
|
||||
'actor' => $p,
|
||||
'object' => $location['hubloc_id_url'],
|
||||
|
@ -339,20 +341,21 @@ class ActivityPub
|
|||
if (!$p) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isNomadic = PConfig::Get($x['sender']['channel_id'], 'system', 'nomadicAP');
|
||||
$rootPath = (($isNomadic) ? Channel::getDidResolver($x['sender']) : z_root());
|
||||
$msg = array_merge(
|
||||
Activity::ap_context(),
|
||||
[
|
||||
'id' => z_root() . '/follow/' . $x['recipient']['abook_id'] . '/' . md5($accept),
|
||||
'id' => $rootPath . '/follow/' . $x['recipient']['abook_id'] . '/' . md5($accept),
|
||||
'type' => 'Accept',
|
||||
'actor' => $p,
|
||||
'object' => [
|
||||
'type' => (($follow_type) ?: 'Follow'),
|
||||
'id' => $accept,
|
||||
'actor' => $x['recipient']['xchan_hash'],
|
||||
'actor' => $x['recipient']['xchan_guid'],
|
||||
'object' => Channel::getDidResolver($x['sender'], true)
|
||||
],
|
||||
'to' => [$x['recipient']['xchan_hash']],
|
||||
'to' => [$x['recipient']['xchan_guid']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
|
@ -384,15 +387,17 @@ class ActivityPub
|
|||
return;
|
||||
}
|
||||
|
||||
$isNomadic = PConfig::Get($x['sender']['channel_id'], 'system', 'nomadicAP');
|
||||
|
||||
$msg = array_merge(
|
||||
Activity::ap_context(),
|
||||
[
|
||||
'id' => z_root() . '/channel/' . $x['sender']['channel_address'] . '#update',
|
||||
'id' => Channel::getDidResolver($x['sender'], true) . '#update',
|
||||
'type' => 'Update',
|
||||
'updated' => Time::convert(format: ISO8601),
|
||||
'actor' => $p,
|
||||
'object' => z_root() . '/channel/' . $x['sender']['channel_address'],
|
||||
'to' => [z_root() . '/followers/' . $x['sender']['channel_address']],
|
||||
'object' => Channel::getDidResolver($x['sender'], true),
|
||||
'to' => [($isNomadic) ? Channel::getDidResolver($x['sender']) . 'actor/followers' : z_root() . '/followers/' . $x['sender']['channel_address']],
|
||||
'cc' => [ACTIVITY_PUBLIC_INBOX]
|
||||
]
|
||||
);
|
||||
|
@ -439,6 +444,9 @@ class ActivityPub
|
|||
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
|
||||
|
||||
$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']) {
|
||||
// was never approved
|
||||
|
||||
|
||||
$msg = array_merge(
|
||||
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',
|
||||
'actor' => $p,
|
||||
'object' => [
|
||||
'type' => 'Follow',
|
||||
'id' => $orig_activity,
|
||||
'actor' => $recip[0]['xchan_hash'],
|
||||
'actor' => $recip[0]['xchan_guid'],
|
||||
'object' => $p
|
||||
],
|
||||
'to' => [$recip[0]['xchan_hash']],
|
||||
'to' => [$recip[0]['xchan_guid']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
|
@ -469,16 +478,16 @@ class ActivityPub
|
|||
$msg = array_merge(
|
||||
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',
|
||||
'actor' => $p,
|
||||
'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',
|
||||
'actor' => $p,
|
||||
'object' => $recip[0]['xchan_hash']
|
||||
'object' => $recip[0]['xchan_guid']
|
||||
],
|
||||
'to' => [$recip[0]['xchan_hash']],
|
||||
'to' => [$recip[0]['xchan_guid']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
|
|
|
@ -2080,10 +2080,13 @@ class Channel
|
|||
return self::getDid($channel);
|
||||
}
|
||||
|
||||
public static function getVerifier($channel)
|
||||
public static function getVerifier($channel, $id = '')
|
||||
{
|
||||
$pubkey = (new Multibase())->publicKey($channel['channel_epubkey']);
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class JcsEddsa2022
|
|||
'type' => 'DataIntegrityProof',
|
||||
'cryptosuite' => 'eddsa-jcs-2022',
|
||||
'created' => Time::convert(format: ISO8601),
|
||||
'verificationMethod' => Channel::getVerifier($channel),
|
||||
'verificationMethod' => Channel::getVerifier($channel, $data['id'] ?? ''),
|
||||
'proofPurpose' => 'assertionMethod',
|
||||
];
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Code\Module;
|
||||
|
||||
use App;
|
||||
use Code\Lib\PConfig;
|
||||
use Code\Web\Controller;
|
||||
use Code\Lib\Libsync;
|
||||
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_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([
|
||||
'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'),
|
||||
'actor' => $actor,
|
||||
'object' => $r[0]['xchan_url']
|
||||
'object' => $r[0]['xchan_guid']
|
||||
], $chan);
|
||||
}
|
||||
|
||||
|
@ -146,7 +148,7 @@ class Follow extends Controller
|
|||
info(t('Connection added.') . EOL);
|
||||
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
|
||||
|
||||
|
|
14
src/Module/Privacy_policy.php
Normal file
14
src/Module/Privacy_policy.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Code\Module;
|
||||
|
||||
use Code\Web\Controller;
|
||||
|
||||
class Privacy_policy extends Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
goaway('/legal');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue