mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-22 01:55:14 +00:00
Merge branch 'dev' of /home/macgirvin/z into dev
This commit is contained in:
commit
38c2ebd29c
8 changed files with 160 additions and 85 deletions
31
Zotlabs/Daemon/Channel_purge.php
Normal file
31
Zotlabs/Daemon/Channel_purge.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zotlabs\Daemon;
|
||||||
|
|
||||||
|
|
||||||
|
class Channel_purge {
|
||||||
|
|
||||||
|
static public function run($argc,$argv) {
|
||||||
|
|
||||||
|
cli_startup();
|
||||||
|
|
||||||
|
$channel_id = intval($argv[1]);
|
||||||
|
|
||||||
|
$channel = q("select * from channel where channel_id = %d and channel_removed = 1");
|
||||||
|
|
||||||
|
if (! $channel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
$r = q("select id from item where uid = %d and item_deleted = 0 limit 1000",
|
||||||
|
intval($channel_id)
|
||||||
|
);
|
||||||
|
if ($r) {
|
||||||
|
foreach ($r as $rv) {
|
||||||
|
drop_item($rv['id'],false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ($r);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3071,30 +3071,30 @@ class Activity {
|
||||||
$x = item_store($item);
|
$x = item_store($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fetch_parents && $parent && ! intval($parent[0]['item_private'])) {
|
// if ($fetch_parents && $parent && ! intval($parent[0]['item_private'])) {
|
||||||
logger('topfetch', LOGGER_DEBUG);
|
// logger('topfetch', LOGGER_DEBUG);
|
||||||
// if the thread owner is a connnection, we will already receive any additional comments to their posts
|
// // if the thread owner is a connnection, we will already receive any additional comments to their posts
|
||||||
// but if they are not we can try to fetch others in the background
|
// // but if they are not we can try to fetch others in the background
|
||||||
$x = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
|
// $x = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
|
||||||
WHERE abook_channel = %d and abook_xchan = '%s' LIMIT 1",
|
// WHERE abook_channel = %d and abook_xchan = '%s' LIMIT 1",
|
||||||
intval($channel['channel_id']),
|
// intval($channel['channel_id']),
|
||||||
dbesc($parent[0]['owner_xchan'])
|
// dbesc($parent[0]['owner_xchan'])
|
||||||
);
|
// );
|
||||||
if (! $x) {
|
// if (! $x) {
|
||||||
// determine if the top-level post provides a replies collection
|
// // determine if the top-level post provides a replies collection
|
||||||
if ($parent[0]['obj']) {
|
// if ($parent[0]['obj']) {
|
||||||
$parent[0]['obj'] = json_decode($parent[0]['obj'],true);
|
// $parent[0]['obj'] = json_decode($parent[0]['obj'],true);
|
||||||
}
|
// }
|
||||||
logger('topfetch: ' . print_r($parent[0],true), LOGGER_ALL);
|
// logger('topfetch: ' . print_r($parent[0],true), LOGGER_ALL);
|
||||||
$id = ((array_path_exists('obj/replies/id',$parent[0])) ? $parent[0]['obj']['replies']['id'] : false);
|
// $id = ((array_path_exists('obj/replies/id',$parent[0])) ? $parent[0]['obj']['replies']['id'] : false);
|
||||||
if (! $id) {
|
// if (! $id) {
|
||||||
$id = ((array_path_exists('obj/replies',$parent[0]) && is_string($parent[0]['obj']['replies'])) ? $parent[0]['obj']['replies'] : false);
|
// $id = ((array_path_exists('obj/replies',$parent[0]) && is_string($parent[0]['obj']['replies'])) ? $parent[0]['obj']['replies'] : false);
|
||||||
}
|
// }
|
||||||
if ($id) {
|
// if ($id) {
|
||||||
Run::Summon( [ 'Convo', $id, $channel['channel_id'], $observer_hash ] );
|
// Run::Summon( [ 'Convo', $id, $channel['channel_id'], $observer_hash ] );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (is_array($x) && $x['item_id']) {
|
if (is_array($x) && $x['item_id']) {
|
||||||
if ($is_child_node) {
|
if ($is_child_node) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ class ActivityPub {
|
||||||
|
|
||||||
// logger('notifier_array: ' . print_r($arr,true), LOGGER_ALL, LOG_INFO);
|
// logger('notifier_array: ' . print_r($arr,true), LOGGER_ALL, LOG_INFO);
|
||||||
|
|
||||||
|
$purge_all = (($arr['packet_type'] === 'purge' && (! intval($arr['private']))) ? true : false);
|
||||||
|
|
||||||
$signed_msg = null;
|
$signed_msg = null;
|
||||||
|
|
||||||
|
@ -47,36 +48,13 @@ class ActivityPub {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$target_item = $arr['target_item'];
|
if ($purge_all) {
|
||||||
|
|
||||||
if (! $target_item['mid']) {
|
$ti = [
|
||||||
return;
|
'id' => channel_url($channel) . '#delete',
|
||||||
}
|
'type' => 'Delete',
|
||||||
|
'obj' => channel_url($channel)
|
||||||
$prv_recips = $arr['env_recips'];
|
];
|
||||||
|
|
||||||
|
|
||||||
if ($signed_msg) {
|
|
||||||
$jmsg = $signed_msg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ti = Activity::encode_activity($target_item, true);
|
|
||||||
if (! $ti) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = IConfig::get($target_item['id'],'ocap','relay');
|
|
||||||
if ($token) {
|
|
||||||
if (defined('USE_BEARCAPS')) {
|
|
||||||
$ti['id'] = 'bear:?u=' . $ti['id'] . '&t=' . $token;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ti['id'] = $ti['id'] . '?token=' . $token;
|
|
||||||
}
|
|
||||||
if ($ti['url'] && is_string($ti['url'])) {
|
|
||||||
$ti['url'] .= '?token=' . $token;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$msg = array_merge(['@context' => [
|
$msg = array_merge(['@context' => [
|
||||||
ACTIVITYSTREAMS_JSONLD_REV,
|
ACTIVITYSTREAMS_JSONLD_REV,
|
||||||
|
@ -86,11 +64,56 @@ class ActivityPub {
|
||||||
|
|
||||||
$msg['signature'] = LDSignatures::sign($msg,$arr['channel']);
|
$msg['signature'] = LDSignatures::sign($msg,$arr['channel']);
|
||||||
|
|
||||||
logger('ActivityPub_encoded: ' . json_encode($msg,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
logger('ActivityPub_encoded (purge_all): ' . json_encode($msg,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
$jmsg = json_encode($msg, JSON_UNESCAPED_SLASHES);
|
$jmsg = json_encode($msg, JSON_UNESCAPED_SLASHES);
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$target_item = $arr['target_item'];
|
||||||
|
|
||||||
|
if (! $target_item['mid']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$prv_recips = $arr['env_recips'];
|
||||||
|
|
||||||
|
|
||||||
|
if ($signed_msg) {
|
||||||
|
$jmsg = $signed_msg;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ti = Activity::encode_activity($target_item, true);
|
||||||
|
if (! $ti) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = IConfig::get($target_item['id'],'ocap','relay');
|
||||||
|
if ($token) {
|
||||||
|
if (defined('USE_BEARCAPS')) {
|
||||||
|
$ti['id'] = 'bear:?u=' . $ti['id'] . '&t=' . $token;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ti['id'] = $ti['id'] . '?token=' . $token;
|
||||||
|
}
|
||||||
|
if ($ti['url'] && is_string($ti['url'])) {
|
||||||
|
$ti['url'] .= '?token=' . $token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg = array_merge(['@context' => [
|
||||||
|
ACTIVITYSTREAMS_JSONLD_REV,
|
||||||
|
'https://w3id.org/security/v1',
|
||||||
|
Activity::ap_schema()
|
||||||
|
]], $ti);
|
||||||
|
|
||||||
|
$msg['signature'] = LDSignatures::sign($msg,$arr['channel']);
|
||||||
|
|
||||||
|
logger('ActivityPub_encoded: ' . json_encode($msg,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
$jmsg = json_encode($msg, JSON_UNESCAPED_SLASHES);
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($prv_recips) {
|
if ($prv_recips) {
|
||||||
$hashes = [];
|
$hashes = [];
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ class Activity extends Controller {
|
||||||
$items = fetch_post_tags($r,false);
|
$items = fetch_post_tags($r,false);
|
||||||
|
|
||||||
if ($portable_id && (! intval($items[0]['item_private']))) {
|
if ($portable_id && (! intval($items[0]['item_private']))) {
|
||||||
$c = q("select abook_id from abook where abook_channel = %d andd abook_xchan = '%s'",
|
$c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s'",
|
||||||
intval($items[0]['uid']),
|
intval($items[0]['uid']),
|
||||||
dbesc($portable_id)
|
dbesc($portable_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -249,7 +249,7 @@ class Item extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($portable_id && (! intval($items[0]['item_private']))) {
|
if ($portable_id && (! intval($items[0]['item_private']))) {
|
||||||
$c = q("select abook_id from abook where abook_channel = %d andd abook_xchan = '%s'",
|
$c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s'",
|
||||||
intval($items[0]['uid']),
|
intval($items[0]['uid']),
|
||||||
dbesc($portable_id)
|
dbesc($portable_id)
|
||||||
);
|
);
|
||||||
|
|
54
boot.php
54
boot.php
|
@ -848,7 +848,6 @@ class App {
|
||||||
|
|
||||||
self::$query_string = '';
|
self::$query_string = '';
|
||||||
|
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|
||||||
set_include_path(
|
set_include_path(
|
||||||
|
@ -857,27 +856,30 @@ class App {
|
||||||
. '.'
|
. '.'
|
||||||
);
|
);
|
||||||
|
|
||||||
self::$scheme = 'http';
|
// normally self::$hostname (also scheme and port) will be filled in during startup.
|
||||||
if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
|
// Set it manually from $_SERVER variables only if it wasn't.
|
||||||
self::$scheme = 'https';
|
|
||||||
elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
|
|
||||||
self::$scheme = 'https';
|
|
||||||
|
|
||||||
if(x($_SERVER,'SERVER_NAME')) {
|
if (! self::$hostname) {
|
||||||
self::$hostname = punify($_SERVER['SERVER_NAME']);
|
self::$hostname = punify(get_host());
|
||||||
|
self::$scheme = 'http';
|
||||||
|
|
||||||
|
if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
|
||||||
|
self::$scheme = 'https';
|
||||||
|
elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
|
||||||
|
self::$scheme = 'https';
|
||||||
|
|
||||||
if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
|
if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
|
||||||
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
|
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
|
||||||
|
|
||||||
/*
|
|
||||||
* Figure out if we are running at the top of a domain
|
|
||||||
* or in a sub-directory and adjust accordingly
|
|
||||||
*/
|
|
||||||
$path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
|
|
||||||
if(isset($path) && strlen($path) && ($path != self::$path))
|
|
||||||
self::$path = $path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Figure out if we are running at the top of a domain
|
||||||
|
* or in a sub-directory and adjust accordingly
|
||||||
|
*/
|
||||||
|
$path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
|
||||||
|
if(isset($path) && strlen($path) && ($path != self::$path))
|
||||||
|
self::$path = $path;
|
||||||
|
|
||||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") {
|
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") {
|
||||||
self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4));
|
self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4));
|
||||||
// removing trailing / - maybe a nginx problem
|
// removing trailing / - maybe a nginx problem
|
||||||
|
@ -2505,3 +2507,23 @@ function get_safemode() {
|
||||||
function supported_imagetype($x) {
|
function supported_imagetype($x) {
|
||||||
return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]);
|
return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_host() {
|
||||||
|
if ($host = $_SERVER['HTTP_X_FORWARDED_HOST']) {
|
||||||
|
$elements = explode(',', $host);
|
||||||
|
$host = trim(end($elements));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (! $host = $_SERVER['HTTP_HOST']) {
|
||||||
|
if (! $host = $_SERVER['SERVER_NAME']) {
|
||||||
|
$host = ((! empty($_SERVER['SERVER_ADDR'])) ? $_SERVER['SERVER_ADDR'] : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove port number from host
|
||||||
|
if (strpos($host,':') !== false) {
|
||||||
|
$host = substr($host,0,strpos($host,':'));
|
||||||
|
}
|
||||||
|
return trim($host);
|
||||||
|
}
|
||||||
|
|
|
@ -2173,12 +2173,6 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select id from item where uid = %d", intval($channel_id));
|
|
||||||
if ($r) {
|
|
||||||
foreach ($r as $rv) {
|
|
||||||
drop_item($rv['id'],false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
|
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
|
||||||
dbesc($channel['channel_hash'])
|
dbesc($channel['channel_hash'])
|
||||||
|
@ -2189,6 +2183,10 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// remove items
|
||||||
|
|
||||||
|
Run::Summon( [ 'Channel_purge', $channel_id ] );
|
||||||
|
|
||||||
// if this was the default channel, set another one as default
|
// if this was the default channel, set another one as default
|
||||||
|
|
||||||
if (App::$account['account_default_channel'] == $channel_id) {
|
if (App::$account['account_default_channel'] == $channel_id) {
|
||||||
|
|
|
@ -228,11 +228,12 @@ abstract class dba_driver {
|
||||||
// Procedural functions
|
// Procedural functions
|
||||||
//
|
//
|
||||||
|
|
||||||
function printable($s) {
|
function printable($s, $escape = true) {
|
||||||
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
||||||
$s = str_replace("\x00",'.',$s);
|
$s = str_replace("\x00",'.',$s);
|
||||||
if(x($_SERVER,'SERVER_NAME'))
|
if ($escape) {
|
||||||
$s = escape_tags($s);
|
$s = escape_tags($s);
|
||||||
|
}
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue