diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index e1f17c304..793ed088f 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -7,15 +7,17 @@ class Thumbnail { static public function run($argc,$argv) { - if(! $argc == 2) + if (! ($argc == 2)) { return; + } $c = q("select * from attach where hash = '%s' ", dbesc($argv[1]) ); - if(! $c) + if (! $c) { return; + } $attach = $c[0]; @@ -41,35 +43,34 @@ class Thumbnail { */ call_hooks('thumbnail',$p); - if($p['thumbnail']) { + if ($p['thumbnail']) { return; } - $default_controller = null; $files = glob('Zotlabs/Thumbs/*.php'); - if($files) { - foreach($files as $f) { + if ($files) { + foreach ($files as $f) { $clsname = '\\Zotlabs\\Thumbs\\' . ucfirst(basename($f,'.php')); - if(class_exists($clsname)) { + if (class_exists($clsname)) { $x = new $clsname(); - if(method_exists($x,'Match')) { + if (method_exists($x,'Match')) { $matched = $x->Match($attach['filetype']); - if($matched) { + if ($matched) { $x->Thumb($attach,$preview_style,$preview_width,$preview_height); } } - if(method_exists($x,'MatchDefault')) { + if (method_exists($x,'MatchDefault')) { $default_matched = $x->MatchDefault(substr($attach['filetype'],0,strpos($attach['filetype'],'/'))); - if($default_matched) { + if ($default_matched) { $default_controller = $x; } } } } } - if(($default_controller) + if (($default_controller) && ((! file_exists(dbunescbin($attach['content']) . '.thumb')) || (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) { $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height); diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 6215eaf7f..1b1a393f2 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2518,6 +2518,9 @@ class Activity { if ((! $allowed) && PConfig::Get($channel['channel_id'], 'system','permit_all_mentions') && i_am_mentioned($channel,$item)) { $allowed = true; } + if (absolutely_no_comments($p[0])) { + $allowed = false; + } if (! $allowed) { logger('rejected comment from ' . $item['author_xchan'] . ' for ' . $channel['channel_address']); diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index fbc144d10..a730d944f 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -520,7 +520,7 @@ class Enotify { } if (is_array($datarray['parent_item'])) { - if (LibBlock::fetch_by_entity($datarray['uid'],$datarray['parent_item']['owner_xchan']) || LibBlock::fetch_by_entity($datarray['uid'],$datarray['parent_item']['owner_xchan'])) { + if (LibBlock::fetch_by_entity($datarray['uid'],$datarray['parent_item']['author_xchan']) || LibBlock::fetch_by_entity($datarray['uid'],$datarray['parent_item']['owner_xchan'])) { pop_lang(); return; } diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 7dc4f0da7..b1e180527 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1790,7 +1790,11 @@ class Libzot { $allowed = can_comment_on_post($sender,$parent[0]); } if ((! $allowed) && PConfig::Get($channel['channel_id'], 'system','permit_all_mentions') && i_am_mentioned($channel,$arr)) { - $allowed = true; + // permit_all_mentions bypasses some comment protections, but if comments are disallowed completely + // honour this setting. + if (! absolutely_no_comments($arr)) { + $allowed = true; + } } } diff --git a/include/items.php b/include/items.php index 5138eda1d..9445604d7 100644 --- a/include/items.php +++ b/include/items.php @@ -345,6 +345,26 @@ function can_comment_on_post($observer_xchan, $item) { return false; } + +function absolutely_no_comments($item) { + + if($item['comment_policy'] === 'none') { + return true; + } + + if (intval($item['item_nocomment'])) { + return true; + } + + if(comments_are_now_closed($item)) { + return true; + } + + return false; +} + + + /** * @brief Adds $hash to the item source route specified by $iid. *