Merge branch 'dev' of codeberg.org:streams/streams into dev

This commit is contained in:
Mike Macgirvin 2024-08-11 14:03:18 +10:00
commit 5a4e657d27
12 changed files with 73 additions and 32 deletions

View file

@ -27,7 +27,7 @@ use Code\Lib\Url;
*/
const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1282;
const DB_UPDATE_VERSION = 1283;
const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '13.3';

View file

@ -928,11 +928,8 @@ function builtin_activity_puller($item, &$conv_responses)
foreach ($conv_responses as $mode => $v) {
$url = '';
if (!$item['author']['xchan_name']) {
logger('Unidentified author for item: ' . $item['id']);
logger('Unidentified item: ' . print_r($item,true), LOGGER_DATA);
continue;
}
switch ($mode) {

View file

@ -122,10 +122,6 @@ function collect_recipients($item, &$private_envelope) {
}
// This is a somewhat expensive operation but important.
// Don't send this item to anybody who doesn't have the deliver_stream permission
$recipients = check_deliver_permissions($item,$recipients);
// Add both the author and owner (if different).

View file

@ -2720,7 +2720,7 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0)
intval($item['uid'])
);
} else {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash left join site on site_url = hubloc_url
$chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join site on site_url = hubloc_url
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')");

View file

@ -520,7 +520,6 @@ function check_deliver_permissions($item, $arr, $includeMentions = false)
{
$result = [];
$uid = $item['uid'] ?? 0;
$terms = ((isset($item['term'])) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_GROUP]) : false);
// Find actors we are not delivering to.
$r = q("select * from abconfig where chan = %d and cat = 'system' and k = 'my_perms' and v not like '%%deliver_stream%%'",
intval($uid)
@ -565,16 +564,24 @@ function check_deliver_permissions($item, $arr, $includeMentions = false)
}
}
// Send mentions even if you have no permission to do so. They might allow it.
if ($terms && $includeMentions) {
foreach ($terms as $term) {
$r = q("select * from hubloc where (hubloc_hash = '%s' or hubloc_id_url = '%s') and hubloc_deleted = 0",
dbesc($term['url']),
dbesc($term['url'])
);
$r = Libzot::zot_record_preferred($r);
if ($r && !in_array($r['hubloc_hash'], $result)) {
$result[] = $r['hubloc_hash'];
break;
if ($includeMentions) {
$terms = ((isset($item['term'])) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_GROUP]) : false);
if ($terms === false) {
$items = fetch_post_tags(['item']);
$item = array_shift($items);
$terms = ((isset($item['term'])) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_GROUP]) : false);
}
if ($terms) {
foreach ($terms as $term) {
$r = q("select * from hubloc where (hubloc_hash = '%s' or hubloc_id_url = '%s') and hubloc_deleted = 0",
dbesc($term['url']),
dbesc($term['url'])
);
$r = Libzot::zot_record_preferred($r);
if ($r && !in_array($r['hubloc_hash'], $result)) {
$result[] = $r['hubloc_hash'];
break;
}
}
}
}

View file

@ -529,6 +529,7 @@ class Notifier implements DaemonInterface
else {
self::$private = false;
self::$recipients = collect_recipients($parent_item, self::$private);
self::$recipients = check_deliver_permissions($parent_item, self::$recipients, true);
}
if ($top_level_post && intval($target_item['item_wall'])) {

View file

@ -1831,7 +1831,7 @@ class Activity
[
'id' => $nomadic ? Channel::getDidResolver($channel, true) . '#ed25519key' : $current_url . '#' . $ed25519publicKey,
'type' => 'Multikey',
'controller' => $nomadic ? Channel::getDid($channel) : $current_url,
'controller' => $nomadic ? Channel::getDidResolver($channel, true) : $current_url,
'publicKeyMultibase' => $ed25519publicKey,
]
]));
@ -5210,7 +5210,8 @@ class Activity
->setDenyGid($sourceItem['deny_gid'])
->setPrivate($sourceItem['item_private'])
->setNocomment($sourceItem['item_nocomment'])
->setCommentPolicy($sourceItem['comment_policy']);
->setCommentPolicy($sourceItem['comment_policy'])
->setPostopts($sourceItem['postopts']);
}
$result = post_activity_item($item->toArray(), deliver: $deliver, channel: $channel, observer: $channel, addAndSync: false);
logger('addToCollection: ' . print_r($result, true));

View file

@ -447,7 +447,7 @@ class Channel
[
'hubloc_guid' => $guid,
'hubloc_guid_sig' => $sig,
'hubloc_id_url' => (($system) ? z_root() : Channel::url($ret['channel'])),
'hubloc_id_url' => (($system) ? z_root() : Channel::getDidResolver($ret['channel'],true)),
'hubloc_hash' => $hash,
'hubloc_addr' => self::get_webfinger($ret['channel']),
'hubloc_primary' => intval($primary),
@ -479,7 +479,7 @@ class Channel
'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}",
'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}",
'xchan_addr' => self::get_webfinger($ret['channel']),
'xchan_url' => (($system) ? z_root() : Channel::url($ret['channel'])),
'xchan_url' => (($system) ? z_root() : Channel::getDidResolver($ret['channel'],true)),
'xchan_follow' => z_root() . '/follow?f=&url=%s',
'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'],
'xchan_name' => $ret['channel']['channel_name'],

View file

@ -1815,8 +1815,7 @@ class Libzot
$isMail = (bool) (intval($arr['item_private']) === 2);
if ((!$tag_delivery) && (!$local_public)) {
$allowed = (perm_is_allowed($channel['channel_id'], $sender, $perm));
$allowed = perm_is_allowed($channel['channel_id'], $sender, $perm);
$blocked = LibBlock::fetch($channel['channel_id'], BLOCKTYPE_SERVER);
if ($blocked) {
$h = q(
@ -1854,6 +1853,7 @@ class Libzot
$allowed = true;
}
}
if ($request) {
// Conversation fetches (e.g. $request == true) take place for
// a) new comments on expired posts
@ -1876,10 +1876,8 @@ class Libzot
}
}
if ($isMail) {
if (!perm_is_allowed($channel['channel_id'], $sender, 'post_mail')) {
$allowed = false;
}
if ($isMail && !$allowed) {
$allowed = perm_is_allowed($channel['channel_id'], $sender, 'post_mail');
}
if (get_abconfig($channel['channel_id'], $sender, 'system', 'block_announce', false)) {

View file

@ -16,7 +16,7 @@ class Apgateway extends Controller
public function init()
{
App::$originalRequest = '/' . $_SERVER['REQUEST_URI'];
App::$originalRequest = $_SERVER['REQUEST_URI'];
// Concatenate path components starting with argv(1)
// to isolate the DID URL.
$url = null;

41
src/Update/_1283.php Normal file
View file

@ -0,0 +1,41 @@
<?php
namespace Code\Update;
use Code\Lib\Channel;
use Code\Lib\PConfig;
class _1283
{
public function run()
{
$channels = q("select * from channel left join xchan on channel_hash = xchan_hash and xchan_network like ('%s')",
dbesc('nomad%')
);
if ($channels) {
foreach ($channels as $channel) {
$nomadic = (PConfig::Get($channel['channel_id'], 'system', 'nomadicAP') || $channel['xchan_network'] === 'nomadic');
if ($nomadic) {
q("UPDATE xchan set xchan_url = '%s' where xchan_id = %d",
dbesc(Channel::getDidResolver($channel, true)),
intval($channel['xchan_id'])
);
q("UPDATE hubloc set hubloc_id_url = '%s' where hubloc_hash = '%s'",
dbesc(Channel::getDidResolver($channel, true)),
dbesc($channel['xchan_hash'])
);
}
}
}
return UPDATE_SUCCESS;
}
public function verify()
{
return true;
}
}

View file

@ -1,2 +1,2 @@
<?php
define ('STD_VERSION', '24.08.03');
define ('STD_VERSION', '24.08.08');