diff options
author | Mario <mario@mariovavti.com> | 2021-10-03 07:11:27 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-10-03 07:11:27 +0000 |
commit | 9de8aefa98e4ea040db41923c2089edc5efb01a8 (patch) | |
tree | b174225fd5b06afeefa34e89d6b57877c7544f08 | |
parent | 66c273ae8d54588dc83e1da6e67c71030abeefa3 (diff) | |
parent | b27fbf209e57e95c94de7667500ef8e7c63e638b (diff) | |
download | volse-hubzilla-9de8aefa98e4ea040db41923c2089edc5efb01a8.tar.gz volse-hubzilla-9de8aefa98e4ea040db41923c2089edc5efb01a8.tar.bz2 volse-hubzilla-9de8aefa98e4ea040db41923c2089edc5efb01a8.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Channel.php | 2 | ||||
-rw-r--r-- | include/channel.php | 48 | ||||
-rw-r--r-- | include/import.php | 3 |
4 files changed, 31 insertions, 24 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 0ae887932..64f192bb2 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -170,7 +170,7 @@ class Notifier { elseif ($cmd === 'refresh_all') { logger('notifier: refresh_all: ' . $item_id); - self::$channel = channelx_by_n($item_id); + self::$channel = channelx_by_n($item_id, true); $r = q("select abook_xchan from abook where abook_channel = %d", intval($item_id) diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index f726426ad..a2e23b31e 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -60,7 +60,7 @@ class Channel extends Controller { dbesc($which) ); - $channel = $r[0]; + $channel = channelx_by_nick($which, true); if (!$channel) { http_status_exit(404, 'Not found'); diff --git a/include/channel.php b/include/channel.php index ca6d01498..ca0c474a3 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2455,23 +2455,23 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { * - array with channel entry * - false if no channel with $nick was found */ -function channelx_by_nick($nick) { +function channelx_by_nick($nick, $removed = false) { // If we are provided a Unicode nickname convert to IDN $nick = punify($nick); - // return a cached copy if there is a cached copy and it's a match + $sql_extra = ' AND channel_removed = 0 '; - if (App::$channel && is_array(App::$channel) && array_key_exists('channel_address',App::$channel) && App::$channel['channel_address'] === $nick) { - return App::$channel; + if ($removed) { + $sql_extra = ''; } - $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' $sql_extra LIMIT 1", dbesc($nick) ); - return(($r) ? $r[0] : false); + return (($r) ? $r[0] : false); } /** @@ -2480,17 +2480,19 @@ function channelx_by_nick($nick) { * @param string $hash * @return array|boolean false if channel ID not found, otherwise the channel array */ -function channelx_by_hash($hash) { +function channelx_by_hash($hash, $removed = false) { - if (App::$channel && is_array(App::$channel) && array_key_exists('channel_hash',App::$channel) && App::$channel['channel_hash'] === $hash) { - return App::$channel; + $sql_extra = ' AND channel_removed = 0 '; + + if ($removed) { + $sql_extra = ''; } - $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' $sql_extra LIMIT 1", dbesc($hash) ); - return(($r) ? $r[0] : false); + return (($r) ? $r[0] : false); } @@ -2500,17 +2502,19 @@ function channelx_by_hash($hash) { * @param string $hash * @return array|boolean false if channel ID not found, otherwise the channel array */ -function channelx_by_portid($hash) { +function channelx_by_portid($hash, $removed = false) { + + $sql_extra = ' AND channel_removed = 0 '; - if (App::$channel && is_array(App::$channel) && array_key_exists('channel_portable_id',App::$channel) && intval(App::$channel['channel_portable_id']) === intval($hash)) { - return App::$channel; + if ($removed) { + $sql_extra = ''; } - $r = q("SELECT * FROM channel left join xchan on channel_portable_id = xchan_hash WHERE channel_portable_id = '%s' and channel_removed = 0 LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_portable_id = xchan_hash WHERE channel_portable_id = '%s' $sql_extra LIMIT 1", dbesc($hash) ); - return(($r) ? $r[0] : false); + return (($r) ? $r[0] : false); } /** @@ -2519,17 +2523,19 @@ function channelx_by_portid($hash) { * @param int $id A channel ID * @return array|boolean false if channel ID not found, otherwise the channel array */ -function channelx_by_n($id) { +function channelx_by_n($id, $removed = false) { + + $sql_extra = ' AND channel_removed = 0 '; - if (App::$channel && is_array(App::$channel) && array_key_exists('channel_id',App::$channel) && intval(App::$channel['channel_id']) === intval($id)) { - return App::$channel; + if ($removed) { + $sql_extra = ''; } - $r = q("SELECT * FROM channel LEFT JOIN xchan ON channel_hash = xchan_hash WHERE channel_id = %d AND channel_removed = 0 LIMIT 1", + $r = q("SELECT * FROM channel LEFT JOIN xchan ON channel_hash = xchan_hash WHERE channel_id = %d $sql_extra = 0 LIMIT 1", intval($id) ); - return(($r) ? $r[0] : false); + return (($r) ? $r[0] : false); } /** diff --git a/include/import.php b/include/import.php index f635f3705..6e25f4154 100644 --- a/include/import.php +++ b/include/import.php @@ -238,7 +238,8 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) { 'id' => $hubloc['hubloc_guid'], 'id_sig' => $hubloc['hubloc_guid_sig'], 'location' => $hubloc['hubloc_url'], - 'location_sig' => $hubloc['hubloc_url_sig'] + 'location_sig' => $hubloc['hubloc_url_sig'], + 'site_id' => $hubloc['hubloc_site_id'] ]; if (($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) { |