diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 12 | ||||
-rw-r--r-- | Zotlabs/Lib/Activity.php | 158 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/Connect.php | 8 | ||||
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 30 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 15 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Activity.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Embedphotos.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Magic.php | 19 | ||||
-rw-r--r-- | Zotlabs/Module/Moderate.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Network.php | 26 | ||||
-rw-r--r-- | Zotlabs/Module/Owa.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Photos.php | 21 | ||||
-rw-r--r-- | Zotlabs/Module/Sse_bs.php | 16 | ||||
-rw-r--r-- | Zotlabs/Module/Zot_probe.php | 12 | ||||
-rw-r--r-- | Zotlabs/Zot6/Zot6Handler.php | 8 |
18 files changed, 170 insertions, 184 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 043b406cc..9fdb1defb 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -323,7 +323,13 @@ class Notifier { self::$encoded_item = json_decode($m, true); } else { - self::$encoded_item = Activity::build_packet(Activity::encode_activity($target_item), self::$channel, false); + $activity = Activity::encode_activity($target_item); + + if (!$activity) { + return; + } + + self::$encoded_item = Activity::build_packet($activity, self::$channel, false); } logger('target_item: ' . print_r($target_item, true), LOGGER_DEBUG); @@ -340,6 +346,10 @@ class Notifier { $relay_to_owner = (!$top_level_post && intval($target_item['item_origin']) && comment_local_origin($target_item)); + if (self::$channel['channel_hash'] === $target_item['owner_xchan']) { + $relay_to_owner = false; + } + // $cmd === 'relay' indicates the owner is sending it to the original recipients // don't allow the item in the relay command to relay to owner under any circumstances, it will loop diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1f7d4be0c..4e04283ba 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -165,7 +165,7 @@ class Activity { } else { logger('fetch failed: ' . $url); - logger($x['body']); + logger(print_r($x, true), LOGGER_DEBUG); } @@ -695,7 +695,7 @@ class Activity { if (is_array($t) && !array_key_exists('type', $t)) $t['type'] = 'Hashtag'; - if (is_array($t) && (array_key_exists('href', $t) || array_key_exists('id', $t)) && array_key_exists('name', $t)) { + if (is_array($t) && (array_key_exists('href', $t) || array_key_exists('id', $t) || isset($t['icon']['url'])) && array_key_exists('name', $t)) { switch ($t['type']) { case 'Hashtag': $ret[] = ['ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '#') ? substr($t['name'], 1) : $t['name'])]; @@ -710,7 +710,7 @@ class Activity { break; case 'Emoji': - $ret[] = ['ttype' => TERM_EMOJI, 'url' => $t['id'], 'term' => escape_tags($t['name']), 'imgurl' => $t['icon']['url']]; + $ret[] = ['ttype' => TERM_EMOJI, 'url' => $t['id'] ?? $t['icon']['url'], 'term' => escape_tags($t['name']), 'imgurl' => $t['icon']['url']]; break; default: @@ -942,36 +942,8 @@ class Activity { } - if ($ret['type'] === 'emojiReaction') { - // There may not be an object for these items for legacy reasons - it should be the conversation parent. - $p = q("select * from item where mid = '%s' and uid = %d", - dbesc($i['parent_mid']), - intval($i['uid']) - ); - if ($p) { - xchan_query($p, true); - $p = fetch_post_tags($p); - $i['obj'] = self::encode_item($p[0]); - - // convert to zot6 emoji reaction encoding which uses the target object to indicate the - // specific emoji instead of overloading the verb or type. - - $im = explode('#', $i['verb']); - if ($im && count($im) > 1) - $emoji = $im[1]; - if (preg_match("/\[img(.*?)\](.*?)\[\/img\]/ism", $i['body'], $match)) { - $ln = $match[2]; - } - - $i['tgt_type'] = 'Image'; - - $i['target'] = [ - 'type' => 'Image', - 'name' => $emoji, - 'url' => (($ln) ? $ln : z_root() . '/images/emoji/' . $emoji . '.png') - ]; - - } + if ($ret['type'] === 'EmojiReact') { + $ret['content'] = $i['body']; } if (strpos($i['mid'], z_root() . '/item/') !== false) { @@ -986,15 +958,15 @@ class Activity { $ret['diaspora:guid'] = $i['uuid']; - if (isset($i['title']) && $i['title']) - $ret['name'] = html2plain(bbcode($i['title'], ['cache' => true])); + if (!empty($i['title'])) + $ret['name'] = html2plain(bbcode($i['title'])); - if (isset($i['summary']) && $i['summary']) - $ret['summary'] = bbcode($i['summary'], ['cache' => true]); + if (!empty($i['summary'])) + $ret['summary'] = bbcode($i['summary']); if ($ret['type'] === 'Announce') { $tmp = preg_replace('/\[share(.*?)\[\/share\]/ism', EMPTY_STR, $i['body']); - $ret['content'] = bbcode($tmp, ['cache' => true]); + $ret['content'] = bbcode($tmp); $ret['source'] = [ 'content' => $i['body'], 'mediaType' => 'text/bbcode' @@ -1010,7 +982,7 @@ class Activity { } } - if (isset($i['app']) && $i['app']) { + if (!empty($i['app'])) { $ret['generator'] = ['type' => 'Application', 'name' => $i['app']]; } if (!empty($i['location']) || !empty($i['coord'])) { @@ -1062,7 +1034,7 @@ class Activity { else return []; - if (isset($i['obj']) && $i['obj']) { + if (!empty($i['obj'])) { if (!is_array($i['obj'])) { $i['obj'] = json_decode($i['obj'], true); } @@ -1090,7 +1062,7 @@ class Activity { $ret['type'] = 'Invite'; } - if (isset($i['target']) && $i['target']) { + if (!empty($i['target'])) { if (!is_array($i['target'])) { $i['target'] = json_decode($i['target'], true); } @@ -1101,12 +1073,10 @@ class Activity { return []; } -/* this should not be needed $t = self::encode_taxonomy($i); if ($t) { $ret['tag'] = $t; } -*/ $a = self::encode_attachment($i, true); if ($a) { @@ -1117,7 +1087,6 @@ class Activity { $ret['to'] = [ACTIVITY_PUBLIC_INBOX]; } - $hookinfo = [ 'item' => $i, 'encoded' => $ret @@ -2148,35 +2117,25 @@ class Activity { $s['owner_xchan'] = $act->actor['id']; $s['author_xchan'] = $act->actor['id']; - $content = []; + $s['mid'] = self::getMessageID($act); - if (is_array($act->obj)) { - $content = self::get_content($act->obj); + if (!$s['mid']) { + return false; } - $s['mid'] = $act->objprop('id'); - - if (!$s['mid'] && is_string($act->obj)) { - $s['mid'] = $act->obj; - } + $s['uuid'] = self::getUUID($act); - // pleroma fetched activities - if (!$s['mid'] && isset($act->obj['data']['id'])) { - $s['mid'] = $act->obj['data']['id']; + if (!$s['uuid']) { + // If we have not found anything useful, create an uuid v5 from the mid + $s['uuid'] = uuid_from_url($s['mid']); } - if ($act->objprop('type') === 'Profile') { - $s['mid'] = $act->id; - } + $content = []; - if (!$s['mid']) { - return false; + if (is_array($act->obj)) { + $content = self::get_content($act->obj); } - // Friendica sends the diaspora guid in a nonstandard field via AP - // If no uuid is provided we will create an uuid v5 from the mid - $s['uuid'] = (($act->objprop('diaspora:guid')) ?: uuid_from_url($s['mid'])); - $s['parent_mid'] = $act->parent_id; if (array_key_exists('published', $act->data)) { @@ -2215,23 +2174,8 @@ class Activity { $response_activity = true; - $s['mid'] = $act->id; - $s['uuid'] = ((!empty($act->data['diaspora:guid'])) ? $act->data['diaspora:guid'] : uuid_from_url($s['mid'])); - $s['parent_mid'] = $act->objprop('id') ?: $act->obj; -/* - if ($act->objprop('inReplyTo')) { - $s['parent_mid'] = $act->objprop('inReplyTo'); - } - - $s['thr_parent'] = $act->objprop('id') ?: $act->obj; - - if (empty($s['parent_mid']) || empty($s['thr_parent'])) { - logger('response activity without parent_mid or thr_parent'); - return; - } -*/ // over-ride the object timestamp with the activity if (isset($act->data['published'])) { @@ -2242,9 +2186,9 @@ class Activity { $s['edited'] = datetime_convert('UTC', 'UTC', $act->data['updated']); } - $obj_actor = $act->objprop('actor') ?: $act->get_actor('attributedTo', $act->obj); + $obj_actor = is_array($act->objprop('actor')) ? $act->objprop('actor') : $act->get_actor('attributedTo', $act->obj); - if (!isset($obj_actor['id'])) { + if (empty($obj_actor['id'])) { return false; } @@ -2280,12 +2224,8 @@ class Activity { $content['content'] = sprintf(t('🔁 Repeated %1$s\'s %2$s'), $mention, $act->obj['type']); } - // TODO: Deprecated - if ($act->type === 'emojiReaction') { - $content['content'] = (($act->tgt && $act->tgt['type'] === 'Image') ? '[img=32x32]' . $act->tgt['url'] . '[/img]' : '&#x' . $act->tgt['name'] . ';'); - } - if (in_array($act->type, ['EmojiReact'])) { + // Pleroma reactions $t = trim(self::get_textfield($act->data, 'content')); @@ -2339,6 +2279,11 @@ class Activity { $s['summary'] = self::bb_content($content, 'summary'); $s['body'] = ((self::bb_content($content, 'bbcode') && (!$response_activity)) ? self::bb_content($content, 'bbcode') : self::bb_content($content, 'content')); + // peertube quirks + if ($act->objprop('mediaType') === 'text/markdown') { + $s['body'] = markdown_to_bb($act->objprop('content')); + } + if ($act->objprop('quoteUrl')) { $quote_bbcode = self::get_quote_bbcode($act->obj['quoteUrl']); @@ -2470,7 +2415,8 @@ class Activity { } } - $tag = (($poster) ? '[video poster="' . $poster . '"]' : '[video]' ); + $tag = (($poster) ? '[video poster=\'' . $poster . '\']' : '[video]' ); + $ptr = null; if ($act->objprop('url')) { @@ -3029,7 +2975,7 @@ class Activity { } } } - +/* if (isset($item['term']) && !PConfig::Get($channel['channel_id'], 'system', 'no_smilies')) { foreach ($item['term'] as $t) { if ($t['ttype'] === TERM_EMOJI) { @@ -3043,6 +2989,7 @@ class Activity { } } } +*/ // TODO: not implemented // self::rewrite_mentions($item); @@ -3872,4 +3819,39 @@ class Activity { return $result; } + + /** + * @brief Retrieves message ID from activity object. + * @param object $act Activity object + * @return string Message ID or empty string if not found + */ + public static function getMessageID($act): string + { + if (ActivityStreams::is_response_activity($act->type) || $act->objprop('type') === 'Profile') { + return $act->id; + } + + return $act->objprop('id', null) + ?? (is_string($act->obj) ? $act->obj : null) + ?? ''; + } + + /** + * @brief Retrieves the UUID from an activity object. + * @param object $act Activity object + * @return string UUID or empty string if not found + */ + public static function getUUID($act): string + { + if (ActivityStreams::is_response_activity($act->type)) { + return $act->data['uuid'] + ?? $act->data['diaspora:guid'] + ?? ''; + } + + return $act->objprop('uuid', null) + ?? $act->objprop('diaspora:guid', null) + ?? ''; + } + } diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 55a1de5dd..f2b9050e3 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -529,8 +529,8 @@ class ActivityStreams { public function checkEddsaSignature() { $signer = $this->get_property_obj('verificationMethod', $this->sig); - $parseUrl = parse_url($signer); + $publicKey = null; if (isset($parseUrl['fragment'])) { if (str_starts_with($parseUrl['fragment'], 'z6Mk')) { diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php index b8e7a5c4e..9f6d077b4 100644 --- a/Zotlabs/Lib/Connect.php +++ b/Zotlabs/Lib/Connect.php @@ -24,10 +24,16 @@ class Connect { $uid = $channel['channel_id']; - if (strpos($url,'@') === false && strpos($url,'/') === false) { + // If we get just a channel name and it is not an URL turn it into a local webbie + if (!str_contains($url, '@') && strpos($url,'/') === false) { $url = $url . '@' . App::get_hostname(); } + // Remove a possible leading @ + if (str_starts_with($url, '@')) { + $url = ltrim($url, '@'); + } + $result = [ 'success' => false, 'message' => '' ]; $my_perms = false; diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 9bffc53a0..6820091d5 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -213,28 +213,36 @@ class Enotify { //$possess_desc = str_replace('<!item_type!>',$possess_desc); // "a post" - $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]a %4$s[/zrl]'), + $dest_str = sprintf( + t('%1$s %2$s [zrl=%3$s]a %4$s[/zrl]'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $action, $itemlink, - $item_post_type); + $item_post_type + ); // "George Bull's post" - if($p) - $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]%4$s\'s %5$s[/zrl]'), + if($p) { + $dest_str = sprintf( + t('%1$s %2$s [zrl=%3$s]%4$s\'s %5$s[/zrl]'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $action, $itemlink, - $p[0]['author']['xchan_name'], - $item_post_type); + $parent_item['author']['xchan_name'], + $item_post_type + ); + } // "your post" - if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'), + if ($parent_item['owner']['xchan_hash'] === $recip['channel_hash'] && intval($parent_item['item_wall'])) { + $dest_str = sprintf( + t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $action, $itemlink, - $item_post_type); + $item_post_type + ); + } // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. @@ -308,7 +316,6 @@ class Enotify { $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; $parent_id = $p[0]['id']; - $parent_item = $p[0]; //$verb = ((activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) ? t('disliked') : t('liked')); @@ -321,13 +328,14 @@ class Enotify { $verb = (($moderated) ? t('requested to dislike') : t('disliked')); // "your post" - if($p[0]['owner']['xchan_name'] === $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) + if ($parent_item['author']['xchan_hash'] === $recip['channel_hash']) { $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $verb, $itemlink, $item_post_type ); + } else { pop_lang(); return; diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 60fb5e034..57c110d8b 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1169,10 +1169,6 @@ class Libzot { $raw_activity = $AS->data; $AS = new ActivityStreams($raw_activity['object'], portable_id: $env['sender']); - - // Store the original activity id and type for later usage - $AS->meta['original_id'] = $original_id; - $AS->meta['original_type'] = $original_type; } if (is_array($AS->obj)) { @@ -1853,19 +1849,12 @@ class Libzot { dbesc($arr['author_xchan']) ); - // If we import an add/remove activity ($is_collection_operation) we strip off the - // add/remove part and only process the object. - // When looking up the item to pass it to the notifier for relay, we need to look up - // the original (stripped off) message id which we stored in $act->meta. - - $sql_mid = (($is_collection_operation && $relay && $channel['channel_hash'] === $arr['owner_xchan']) ? $act->meta['original_id'] : $arr['mid']); - // Reactions such as like and dislike could have an mid with /activity/ in it. // Check for both forms in order to prevent duplicates. $r = q("select * from item where mid in ('%s', '%s') and uid = %d limit 1", - dbesc($sql_mid), - dbesc(reverse_activity_mid($sql_mid)), + dbesc($arr['mid']), + dbesc(reverse_activity_mid($arr['mid'])), intval($channel['channel_id']) ); diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index e0db98eb3..d0fa1e587 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -803,7 +803,7 @@ class ThreadItem { '$eduline' => t('Underline'), '$edquote' => t('Quote'), '$edcode' => t('Code'), - '$edimg' => t('Image'), + '$edimg' => t('Embed (existing) photo from your photo albums'), '$edatt' => t('Attach/Upload file'), '$edurl' => t('Insert Link'), '$edvideo' => t('Video'), diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php index 85b9f3e7c..64da2586b 100644 --- a/Zotlabs/Module/Activity.php +++ b/Zotlabs/Module/Activity.php @@ -23,7 +23,7 @@ class Activity extends Controller { if (! $item_id) http_status_exit(404, 'Not found'); - $portable_id = EMPTY_STR; + $portable_id = null; $item_normal_extra = sprintf(" and not verb in ('Follow', 'Ignore', '%s', '%s') ", dbesc(ACTIVITY_FOLLOW), @@ -166,6 +166,7 @@ class Activity extends Controller { return; } + $portable_id = null; $ob_authorize = false; $item_uid = 0; diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php index ed5b24724..edf2d162a 100644 --- a/Zotlabs/Module/Embedphotos.php +++ b/Zotlabs/Module/Embedphotos.php @@ -43,7 +43,7 @@ class Embedphotos extends \Zotlabs\Web\Controller { $arr = explode('/', $href); $resource_id = array_pop($arr); $x = self::photolink($resource_id); - if($x) + if($x) json_return_and_die(array('status' => true, 'photolink' => $x, 'resource_id' => $resource_id)); json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false)); } @@ -55,7 +55,7 @@ class Embedphotos extends \Zotlabs\Web\Controller { $output = EMPTY_STR; if($channel) { $resolution = ((feature_enabled($channel['channel_id'],'large_photos')) ? 1 : 2); - $r = q("select mimetype, height, width from photo where resource_id = '%s' and $resolution = %d and uid = %d limit 1", + $r = q("select mimetype, filename from photo where resource_id = '%s' and $resolution = %d and uid = %d limit 1", dbesc($resource), intval($resolution), intval($channel['channel_id']) @@ -63,6 +63,8 @@ class Embedphotos extends \Zotlabs\Web\Controller { if(! $r) return $output; + $filename = $r[0]['filename']; + if($r[0]['mimetype'] === 'image/jpeg') $ext = '.jpg'; elseif($r[0]['mimetype'] === 'image/png') @@ -75,7 +77,7 @@ class Embedphotos extends \Zotlabs\Web\Controller { $ext = EMPTY_STR; $output = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $resource . ']' . - '[zmg=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . z_root() . '/photo/' . $resource . '-' . $resolution . $ext . '[/zmg][/zrl]'; + '[zmg=' . z_root() . '/photo/' . $resource . '-' . $resolution . $ext . ']' . $filename . '[/zmg][/zrl]' . "\r\n"; return $output; } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index cd024b083..ea561ee25 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -885,19 +885,13 @@ class Item extends Controller { if ($parent_item) $parent_mid = $parent_item['mid']; - // Fallback so that we always have a thr_parent if (!$thr_parent) $thr_parent = $mid; - $item_thread_top = ((!$parent) ? 1 : 0); - if ((!$plink) && ($item_thread_top)) { - $plink = $mid; - } - if (isset($datarray['obj']) && $datarray['obj']) { $datarray['obj']['id'] = $mid; } @@ -960,7 +954,7 @@ class Item extends Controller { $datarray['public_policy'] = $public_policy; $datarray['comment_policy'] = map_scope($comment_policy); $datarray['term'] = array_unique($post_tags, SORT_REGULAR); - $datarray['plink'] = $plink; + $datarray['plink'] = $plink ?? $mid; $datarray['route'] = $route; // A specific ACL over-rides public_policy completely diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index e722a7161..122d90b1b 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -41,11 +41,7 @@ class Magic extends Controller { http_status_exit(400, 'Bad Request'); } - $basepath = unparse_url(array_filter( - $parsed, - fn (string $key) => in_array($key, ['scheme', 'host', 'port']), - ARRAY_FILTER_USE_KEY - )); + $basepath = unparse_url($parsed, ['scheme', 'host', 'port']); $owapath = SConfig::get($basepath, 'system', 'openwebauth', $basepath . '/owa'); @@ -134,11 +130,22 @@ class Magic extends Controller { $args = (($x) ? '&owt=' . $token : '?owt=' . $token) . (($delegate) ? '&delegate=1' : ''); goaway($dest . $args); } + else { + $o = '<h1>OWA ERROR</h1>'; + if (!empty($j['message'])) { + $o .= '<h2>' . $j['message'] . '</h2>'; + } + $o .= '<a href=' . $dest . '>' . $dest . '</a>'; + + echo $o; + killme(); + + } } } } - killme(); + goaway($dest); } diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index 2103684ab..1d8f65348 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -67,7 +67,7 @@ class Moderate extends \Zotlabs\Web\Controller { $item['item_blocked'] = 0; item_update_parent_commented($item); - notice( t('Item approved') . EOL); + info(t('Item approved') . EOL); } elseif($action === 'drop') { // TODO: not implemented @@ -75,7 +75,7 @@ class Moderate extends \Zotlabs\Web\Controller { // Activity::send_rejection_activity(App::get_channel(), $item['author_xchan'], $item); drop_item($post_id); - notice( t('Item deleted') . EOL); + info(t('Item deleted') . EOL); } // refetch the item after changes have been made diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 3ea813547..5573ed469 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -278,32 +278,12 @@ class Network extends \Zotlabs\Web\Controller { $likes_sql = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; // This is for nouveau view public forum cid queries (if a forum notification is clicked) - //$p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'", - //intval(local_channel()), - //intval(TERM_FORUM), - //dbesc($cid_r[0]['xchan_name']) - //); + $sql_extra = " AND item.parent IN (SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal) AND item_unseen = 1 AND verb != 'Announce' $likes_sql "; - //$p_str = ids_to_querystr($p, 'parent'); - - $p_sql = ''; - //if($p_str) - //$p_sql = " OR item.parent IN ( $p_str ) "; - - $sql_extra = " AND ( owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' OR owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' $p_sql ) AND item_unseen = 1 $likes_sql "; } else { // This is for threaded view cid queries (e.g. if a forum is selected from the forum filter) - $ttype = (($pf) ? TERM_FORUM : TERM_MENTION); - - $p1 = dbq("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal "); - $p2 = dbq("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); - - $p_str = ids_to_querystr(array_merge($p1, $p2), 'parent'); - if(! $p_str) - killme(); - - $sql_extra = " AND item.parent IN ( $p_str ) "; + $sql_extra = " AND item.parent IN (SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal) "; } } @@ -472,7 +452,7 @@ class Network extends \Zotlabs\Web\Controller { if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order - $items = dbq("SELECT item.*, item.id AS item_id, created FROM item + $items = dbq("SELECT item.*, item.id AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) $net_query WHERE true $uids $item_normal diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 21082e166..254b1c7d1 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -27,6 +27,8 @@ class Owa extends Controller { $this->error('Missing or invalid authorization header.'); } + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_AUTHORIZATION'] ?? $_SERVER['REDIRECT_REMOTE_USER']; + $sigblock = HTTPSig::parse_sigheader($_SERVER['HTTP_AUTHORIZATION']); if ($sigblock) { $keyId = $sigblock['keyId']; diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index e31aa9dc1..132c0ce33 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -557,7 +557,9 @@ class Photos extends \Zotlabs\Web\Controller { $can_post = false; $visitor = 0; - + $link_item = null; + $like = null; + $dislike = null; $owner_uid = \App::$data['channel']['channel_id']; $owner_aid = \App::$data['channel']['channel_account_id']; @@ -965,7 +967,6 @@ class Photos extends \Zotlabs\Web\Controller { $map = null; if($linked_items) { - xchan_query($linked_items); $linked_items = fetch_post_tags($linked_items,true); @@ -1103,9 +1104,6 @@ class Photos extends \Zotlabs\Web\Controller { $alike = array(); $dlike = array(); - $like = ''; - $dislike = ''; - $conv_responses = array( 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) @@ -1217,12 +1215,17 @@ class Photos extends \Zotlabs\Web\Controller { $like_e = $like; $dislike_e = $dislike; $paginate = paginate(); + $responses = []; - $response_verbs = array('like'); - if(feature_enabled($owner_uid,'dislike')) - $response_verbs[] = 'dislike'; + if ($linkitem) { + $response_verbs = ['like']; - $responses = get_responses($conv_responses,$response_verbs,'',$link_item); + if(feature_enabled($owner_uid,'dislike')) { + $response_verbs[] = 'dislike'; + } + + $responses = get_responses($conv_responses,$response_verbs,'',$link_item); + } $hookdata = [ 'onclick' => '$.colorbox({href: \'' . $photo['href'] . '\'}); return false;', diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index d214ba28f..8847ff242 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -602,25 +602,15 @@ class Sse_bs extends Controller { $i = 0; for($x = 0; $x < $fcount; $x ++) { - /* - $p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'", - intval(self::$uid), - intval(TERM_FORUM), - dbesc($forums[$x]['xchan_name']) - ); - - $p_str = ids_to_querystr($p, 'parent'); - $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : ''); - */ $r = q("select count(*) as total from item - where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and verb != 'Announce' and item_unseen = 1 $sql_extra $item_normal", + where uid = %d and (owner_xchan = '%s' or author_xchan = '%s') and author_xchan != '%s' and verb != 'Announce' and item_unseen = 1 $sql_extra $item_normal", intval(self::$uid), dbesc($forums[$x]['xchan_hash']), - dbesc($forums[$x]['xchan_hash']) + dbesc($forums[$x]['xchan_hash']), + dbesc(self::$ob_hash) ); - if($r[0]['total']) { $forums[$x]['notify_link'] = z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']; diff --git a/Zotlabs/Module/Zot_probe.php b/Zotlabs/Module/Zot_probe.php index 3eaabdd92..feb51f071 100644 --- a/Zotlabs/Module/Zot_probe.php +++ b/Zotlabs/Module/Zot_probe.php @@ -9,19 +9,29 @@ class Zot_probe extends \Zotlabs\Web\Controller { function get() { + if (!local_channel()) { + return; + } + $addr = $_GET['addr'] ?? ''; $o = '<h3>Zot6 Probe Diagnostic</h3>'; $o .= '<form action="zot_probe" method="get">'; $o .= 'Lookup URI: <input type="text" style="width: 250px;" name="addr" value="' . $addr .'" /><br>'; + $o .= '<input type="checkbox" name="sign" /> Sign request <br>'; $o .= '<input type="submit" name="submit" value="Submit" /></form>'; $o .= '<br /><br />'; if($addr) { - $x = Zotfinger::exec($addr); + $channel = null; + if ($_GET['sign']) { + $channel = get_sys_channel(); + } + + $x = Zotfinger::exec($addr, $channel); $o .= '<pre>' . htmlspecialchars(print_array($x)) . '</pre>'; diff --git a/Zotlabs/Zot6/Zot6Handler.php b/Zotlabs/Zot6/Zot6Handler.php index 053901205..2ef9e3b8d 100644 --- a/Zotlabs/Zot6/Zot6Handler.php +++ b/Zotlabs/Zot6/Zot6Handler.php @@ -34,11 +34,13 @@ class Zot6Handler implements IHandler { logger('notify received from ' . $hub['hubloc_url']); - $x = Libzot::fetch($data, $hub); - $ret['delivery_report'] = $x; + $x = Libzot::fetch($data); + if ($x) { + $ret['delivery_report'] = $x; + $ret['success'] = true; + } - $ret['success'] = true; return $ret; } |