remove more legacy zot quirks

This commit is contained in:
Mario
2021-05-26 19:02:13 +00:00
parent ff34a787c3
commit 1c8000d026
10 changed files with 49 additions and 72 deletions

View File

@@ -165,11 +165,6 @@ class Cron {
} }
} }
// check if any connections transitioned to zot6 and upgrade the connections to zot6 at this hub if so.
require_once('include/connections.php');
z6trans_connections();
require_once('include/attach.php'); require_once('include/attach.php');
attach_upgrade(); attach_upgrade();

View File

@@ -95,8 +95,6 @@ class Cron_daily {
remove_obsolete_hublocs(); remove_obsolete_hublocs();
remove_duplicate_singleton_hublocs(); remove_duplicate_singleton_hublocs();
z6_discover();
$date = datetime_convert(); $date = datetime_convert();
call_hooks('cron_daily', $date); call_hooks('cron_daily', $date);

View File

@@ -87,8 +87,7 @@ class DReport {
// Is the sender one of our channels? // Is the sender one of our channels?
$c = q("select channel_id from channel where channel_hash = '%s' or channel_portable_id = '%s' limit 1", $c = q("select channel_id from channel where channel_hash = '%s' limit 1",
dbesc($dr['sender']),
dbesc($dr['sender']) dbesc($dr['sender'])
); );

View File

@@ -345,7 +345,7 @@ class Libzotdir {
logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG); logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG);
$p = q("select channel.channel_hash, channel_address, channel_timezone, channel_portable_id, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", $p = q("select channel.channel_hash, channel_address, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1",
intval($uid) intval($uid)
); );
@@ -354,7 +354,6 @@ class Libzotdir {
if ($p) { if ($p) {
$hash = $p[0]['channel_hash']; $hash = $p[0]['channel_hash'];
$legacy_hash = $p[0]['channel_portable_id'];
$profile['description'] = $p[0]['pdesc']; $profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob']; $profile['birthday'] = $p[0]['dob'];
@@ -393,10 +392,9 @@ class Libzotdir {
); );
if(intval($r[0]['xchan_hidden']) != $hidden) { if(intval($r[0]['xchan_hidden']) != $hidden) {
$r = q("update xchan set xchan_hidden = %d where xchan_hash in ('%s', '%s')", $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'",
intval($hidden), intval($hidden),
dbesc($hash), dbesc($hash)
dbesc($legacy_hash)
); );
} }
@@ -410,13 +408,11 @@ class Libzotdir {
} }
else { else {
// they may have made it private // they may have made it private
q("delete from xprof where xprof_hash in ('%s', '%s')", q("delete from xprof where xprof_hash = '%s'",
dbesc($hash), dbesc($hash)
dbesc($legacy_hash)
); );
q("delete from xtag where xtag_hash in ('%s', '%s')", q("delete from xtag where xtag_hash = '%s'",
dbesc($hash), dbesc($hash)
dbesc($legacy_hash)
); );
} }

View File

@@ -5,16 +5,16 @@ namespace Zotlabs\Module;
class Dreport extends \Zotlabs\Web\Controller { class Dreport extends \Zotlabs\Web\Controller {
function get() { function get() {
if(! local_channel()) { if(! local_channel()) {
notice( t('Permission denied') . EOL); notice( t('Permission denied') . EOL);
return; return;
} }
$table = 'item'; $table = 'item';
$channel = \App::get_channel(); $channel = \App::get_channel();
$mid = ((argc() > 1) ? argv(1) : ''); $mid = ((argc() > 1) ? argv(1) : '');
$encoded_mid = ''; $encoded_mid = '';
@@ -31,7 +31,7 @@ class Dreport extends \Zotlabs\Web\Controller {
$mid = @base64url_decode(substr($mid,4)); $mid = @base64url_decode(substr($mid,4));
} }
if($mid) { if($mid) {
$i = q("select id from item where mid = '%s' and uid = %d and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ", $i = q("select id from item where mid = '%s' and uid = %d and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ",
dbesc($mid), dbesc($mid),
intval($channel['channel_id']), intval($channel['channel_id']),
@@ -53,13 +53,13 @@ class Dreport extends \Zotlabs\Web\Controller {
$mid = @base64url_decode(substr($mid,4)); $mid = @base64url_decode(substr($mid,4));
} }
if(! $mid) { if(! $mid) {
notice( t('Invalid message') . EOL); notice( t('Invalid message') . EOL);
return; return;
} }
switch($table) { switch($table) {
case 'item': case 'item':
$i = q("select id from item where mid = '%s' and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ", $i = q("select id from item where mid = '%s' and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ",
@@ -77,30 +77,29 @@ class Dreport extends \Zotlabs\Web\Controller {
default: default:
break; break;
} }
if(! $i) { if(! $i) {
notice( t('Permission denied') . EOL); notice( t('Permission denied') . EOL);
return; return;
} }
$r = q("select * from dreport where (dreport_xchan = '%s' or dreport_xchan = '%s') and dreport_mid = '%s'", $r = q("select * from dreport where dreport_xchan = '%s' and dreport_mid = '%s'",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id']),
dbesc($mid) dbesc($mid)
); );
if(! $r) { if(! $r) {
notice( t('no results') . EOL); notice( t('no results') . EOL);
// return; // return;
} }
for($x = 0; $x < count($r); $x++ ) { for($x = 0; $x < count($r); $x++ ) {
// This has two purposes: 1. make the delivery report strings translateable, and // This has two purposes: 1. make the delivery report strings translateable, and
// 2. assign an ordering to item delivery results so we can group them and provide // 2. assign an ordering to item delivery results so we can group them and provide
// a readable report with more interesting events listed toward the top and lesser // a readable report with more interesting events listed toward the top and lesser
// interesting items towards the bottom // interesting items towards the bottom
switch($r[$x]['dreport_result']) { switch($r[$x]['dreport_result']) {
case 'channel sync processed': case 'channel sync processed':
$r[$x]['gravity'] = 0; $r[$x]['gravity'] = 0;
@@ -146,13 +145,13 @@ class Dreport extends \Zotlabs\Web\Controller {
break; break;
} }
} }
usort($r,'self::dreport_gravity_sort'); usort($r,'self::dreport_gravity_sort');
$entries = array(); $entries = array();
foreach($r as $rr) { foreach($r as $rr) {
$entries[] = [ $entries[] = [
'name' => escape_tags($rr['dreport_name'] ?: $rr['dreport_recip']), 'name' => escape_tags($rr['dreport_name'] ?: $rr['dreport_recip']),
'result' => escape_tags($rr['dreport_result']), 'result' => escape_tags($rr['dreport_result']),
'time' => escape_tags(datetime_convert('UTC',date_default_timezone_get(),$rr['dreport_time'])) 'time' => escape_tags(datetime_convert('UTC',date_default_timezone_get(),$rr['dreport_time']))
]; ];
@@ -167,14 +166,14 @@ class Dreport extends \Zotlabs\Web\Controller {
'$push' => t('Redeliver'), '$push' => t('Redeliver'),
'$entries' => $entries '$entries' => $entries
)); ));
return $o; return $o;
} }
private static function dreport_gravity_sort($a,$b) { private static function dreport_gravity_sort($a,$b) {
if($a['gravity'] == $b['gravity']) { if($a['gravity'] == $b['gravity']) {
if($a['dreport_name'] === $b['dreport_name']) if($a['dreport_name'] === $b['dreport_name'])
@@ -183,5 +182,5 @@ class Dreport extends \Zotlabs\Web\Controller {
} }
return (($a['gravity'] > $b['gravity']) ? 1 : (-1)); return (($a['gravity'] > $b['gravity']) ? 1 : (-1));
} }
} }

View File

@@ -253,9 +253,8 @@ class Import extends \Zotlabs\Web\Controller {
// replace any existing xchan we may have on this site if we're seizing control // replace any existing xchan we may have on this site if we're seizing control
$r = q("delete from xchan where ( xchan_hash = '%s' or xchan_hash = '%s' ) ", $r = q("delete from xchan where xchan_hash = '%s'",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id'])
); );
$r = xchan_store_lowlevel( $r = xchan_store_lowlevel(

View File

@@ -28,9 +28,8 @@ class Locs extends Controller {
return; return;
} }
q("UPDATE hubloc SET hubloc_primary = 0 WHERE hubloc_primary = 1 AND (hubloc_hash = '%s' OR hubloc_hash = '%s')", q("UPDATE hubloc SET hubloc_primary = 0 WHERE hubloc_primary = 1 AND hubloc_hash = '%s'",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id'])
); );
q("UPDATE hubloc SET hubloc_primary = 1 WHERE hubloc_id = %d AND hubloc_hash = '%s'", q("UPDATE hubloc SET hubloc_primary = 1 WHERE hubloc_id = %d AND hubloc_hash = '%s'",
@@ -81,10 +80,9 @@ class Locs extends Controller {
} }
} }
q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_id_url = '%s' AND (hubloc_hash = '%s' OR hubloc_hash = '%s')", q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_id_url = '%s' AND hubloc_hash = '%s'",
dbesc($r[0]['hubloc_id_url']), dbesc($r[0]['hubloc_id_url']),
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id'])
); );
Master::Summon( [ 'Notifier', 'refresh_all', $channel['channel_id'] ] ); Master::Summon( [ 'Notifier', 'refresh_all', $channel['channel_id'] ] );
return; return;

View File

@@ -27,7 +27,7 @@ function api_login(&$a){
if ($server->verifyResourceRequest($request)) { if ($server->verifyResourceRequest($request)) {
$token = $server->getAccessTokenData($request); $token = $server->getAccessTokenData($request);
$uid = $token['user_id']; $uid = $token['user_id'];
$r = q("SELECT * FROM channel WHERE channel_id = %d LIMIT 1", $r = q("SELECT * FROM channel WHERE channel_id = %d LIMIT 1",
intval($uid) intval($uid)
); );
if (count($r)) { if (count($r)) {
@@ -41,7 +41,7 @@ function api_login(&$a){
$_SESSION['uid'] = $record['channel_id']; $_SESSION['uid'] = $record['channel_id'];
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$x = q("select * from account where account_id = %d LIMIT 1", $x = q("select * from account where account_id = %d LIMIT 1",
intval($record['channel_account_id']) intval($record['channel_account_id'])
); );
if ($x) { if ($x) {
@@ -102,9 +102,6 @@ function api_login(&$a){
); );
if($r) { if($r) {
$c = channelx_by_hash($r[0]['hubloc_hash']); $c = channelx_by_hash($r[0]['hubloc_hash']);
if (! $c) {
$c = channelx_by_portid($r[0]['hubloc_hash']);
}
if($c) { if($c) {
$a = q("select * from account where account_id = %d limit 1", $a = q("select * from account where account_id = %d limit 1",
intval($c['channel_account_id']) intval($c['channel_account_id'])
@@ -116,7 +113,7 @@ function api_login(&$a){
} }
} }
if($record) { if($record) {
$verified = \Zotlabs\Web\HTTPSig::verify('',$record['channel']['channel_pubkey']); $verified = \Zotlabs\Web\HTTPSig::verify('',$record['channel']['channel_pubkey']);
if(! ($verified && $verified['header_signed'] && $verified['header_valid'])) { if(! ($verified && $verified['header_signed'] && $verified['header_valid'])) {
$record = null; $record = null;
@@ -164,4 +161,4 @@ function retry_basic_auth($method = 'Basic') {
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
echo('This api requires login'); echo('This api requires login');
killme(); killme();
} }

View File

@@ -2794,15 +2794,12 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
logger('deleting hublocs',LOGGER_DEBUG); logger('deleting hublocs',LOGGER_DEBUG);
$r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_hash = '%s' OR hubloc_hash = '%s'", $r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_hash = '%s'",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id'])
); );
$r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s' OR xchan_hash = '%s'", $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s'",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash'])
dbesc($channel['channel_portable_id'])
); );
Master::Summon(array('Notifier','purge_all',$channel_id)); Master::Summon(array('Notifier','purge_all',$channel_id));

View File

@@ -681,12 +681,11 @@ function get_security_ids($channel_id, $ob_hash) {
]; ];
if ($channel_id) { if ($channel_id) {
$ch = q("select channel_hash, channel_portable_id from channel where channel_id = %d", $ch = q("select channel_hash from channel where channel_id = %d",
intval($channel_id) intval($channel_id)
); );
if ($ch) { if ($ch) {
$ret['channel_id'][] = $ch[0]['channel_hash']; $ret['channel_id'][] = $ch[0]['channel_hash'];
$ret['channel_id'][] = $ch[0]['channel_portable_id'];
} }
} }