aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-08 18:18:44 +0000
committerMario <mario@mariovavti.com>2020-10-08 18:18:44 +0000
commitad51be7dd9446b1338f2e140a479a497f56820f3 (patch)
tree9416dfe42f48046d6e410d6565b81e3ea06438c7
parent3514f805ea93619cb7ea14961974b4d61c36d17d (diff)
downloadvolse-hubzilla-ad51be7dd9446b1338f2e140a479a497f56820f3.tar.gz
volse-hubzilla-ad51be7dd9446b1338f2e140a479a497f56820f3.tar.bz2
volse-hubzilla-ad51be7dd9446b1338f2e140a479a497f56820f3.zip
reduce result set for query in zid_init() and use Libzot::zot_record_preferred() in mod rmagic
-rw-r--r--Zotlabs/Module/Rmagic.php19
-rw-r--r--include/channel.php3
2 files changed, 13 insertions, 9 deletions
diff --git a/Zotlabs/Module/Rmagic.php b/Zotlabs/Module/Rmagic.php
index 8c1e5cdab..ab9ad059e 100644
--- a/Zotlabs/Module/Rmagic.php
+++ b/Zotlabs/Module/Rmagic.php
@@ -1,6 +1,7 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libzot;
class Rmagic extends \Zotlabs\Web\Controller {
@@ -11,23 +12,24 @@ class Rmagic extends \Zotlabs\Web\Controller {
$me = get_my_address();
if($me) {
- $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s'",
dbesc($me)
);
if(! $r) {
$w = discover_by_webbie($me);
if($w) {
- $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s'",
dbesc($me)
);
}
}
- if($r) {
- if($r[0]['hubloc_url'] === z_root())
+ if($r) {
+ $r = Libzot::zot_record_preferred($r);
+ if($r['hubloc_url'] === z_root())
goaway(z_root() . '/login');
$dest = bin2hex(z_root() . '/' . str_replace(['rmagic','zid='],['','zid_='],\App::$query_string));
- goaway($r[0]['hubloc_url'] . '/magic' . '?f=&owa=1&bdest=' . $dest);
+ goaway($r['hubloc_url'] . '/magic' . '?f=&owa=1&bdest=' . $dest);
}
}
}
@@ -55,13 +57,13 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = null;
if($address) {
- $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s'",
dbesc($address)
);
if(! $r) {
$w = discover_by_webbie($address);
if($w) {
- $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s'",
dbesc($address)
);
}
@@ -69,7 +71,8 @@ class Rmagic extends \Zotlabs\Web\Controller {
}
if($r) {
- $url = $r[0]['hubloc_url'];
+ $r = Libzot::zot_record_preferred($r);
+ $url = $r['hubloc_url'];
}
else {
$url = 'https://' . substr($address,strpos($address,'@')+1);
diff --git a/include/channel.php b/include/channel.php
index a51404652..ccec4f9ee 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1925,7 +1925,7 @@ function zid_init() {
call_hooks('zid_init', $arr);
if(! local_channel()) {
- $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc",
+ $r = q("select hubloc_url, hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s' order by hubloc_connected desc",
dbesc($tmp_str)
);
if(! $r) {
@@ -1934,6 +1934,7 @@ function zid_init() {
if($r) {
$r = Libzot::zot_record_preferred($r);
}
+
if($r && remote_channel() && remote_channel() === $r['hubloc_hash'])
return;