mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 15:55:13 +00:00
preliminary work on permitting moderated comments from unknown strangers
This commit is contained in:
parent
2864b99eb1
commit
b5dea507fe
3 changed files with 13 additions and 38 deletions
|
@ -3661,7 +3661,8 @@ class Activity
|
|||
}
|
||||
|
||||
// At this point we know it is allowed, but check if it requires moderation.
|
||||
if (perm_is_allowed($channel['channel_id'], $item['author_xchan'], 'moderated')) {
|
||||
if (perm_is_allowed($channel['channel_id'], $item['author_xchan'], 'moderated')
|
||||
|| $allowed === 'moderated') {
|
||||
$item['item_blocked'] = ITEM_MODERATED;
|
||||
}
|
||||
} else {
|
||||
|
@ -3961,7 +3962,7 @@ class Activity
|
|||
}
|
||||
}
|
||||
|
||||
public static function comment_allowed($channel, $item, $parent_item): bool
|
||||
public static function comment_allowed($channel, $item, $parent_item): bool|string
|
||||
{
|
||||
// First check if comment permissions have been granted to this author.
|
||||
$allowed = perm_is_allowed($channel['channel_id'], $item['author_xchan'], 'post_comments');
|
||||
|
@ -3986,6 +3987,10 @@ class Activity
|
|||
$allowed = ($parent_item['owner_xchan'] !== $channel['channel_hash']);
|
||||
}
|
||||
|
||||
if ((!$allowed) && intval(PConfig::Get($channel['channel_id'],'system','permit_moderated_comments'))) {
|
||||
$allowed = 'moderated';
|
||||
}
|
||||
|
||||
// If the item comment control forbids any comments, this over-rides everything.
|
||||
if (absolutely_no_comments($parent_item)) {
|
||||
$allowed = false;
|
||||
|
|
|
@ -1642,25 +1642,6 @@ class Libzot
|
|||
|
||||
$DR->set_name($channel['channel_name'] . ' <' . Channel::get_webfinger($channel) . '>');
|
||||
|
||||
// if ($act->type === 'Tombstone') {
|
||||
// $r = q("select * from item where mid in ( '%s', '%s' ) and uid = %d",
|
||||
// dbesc($act->id),
|
||||
// dbesc(str_replace('/activity/','/item/',$act->id))
|
||||
// intval($channel['channel_id'])
|
||||
// );
|
||||
// if ($r) {
|
||||
// if (($r[0]['author_xchan'] === $sender) || ($r[0]['owner_xchan'] === $sender)) {
|
||||
// drop_item($r[0]['id']);
|
||||
// }
|
||||
// $DR->update('item deleted');
|
||||
// $result[] = $DR->get();
|
||||
// continue;
|
||||
// }
|
||||
// $DR->update('deleted item not found');
|
||||
// $result[] = $DR->get();
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (($act) && ($act->obj) && (!is_array($act->obj))) {
|
||||
// The initial object fetch failed using the sys channel credentials.
|
||||
// Try again using the delivery channel credentials.
|
||||
|
@ -1788,18 +1769,9 @@ class Libzot
|
|||
dbesc($arr['parent_mid']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($parent) {
|
||||
$allowed = can_comment_on_post($sender, $parent[0]);
|
||||
}
|
||||
if ((!$allowed) && $permit_mentions) {
|
||||
if ($parent && $parent[0]['owner_xchan'] === $channel['channel_hash']) {
|
||||
$allowed = false;
|
||||
} else {
|
||||
$allowed = true;
|
||||
}
|
||||
}
|
||||
if ($parent && absolutely_no_comments($parent[0])) {
|
||||
$allowed = false;
|
||||
$allowed = can_comment_on_post($sender, $parent[0]);
|
||||
if (! $allowed) {
|
||||
$allowed = Activity::comment_allowed($channel, $arr, $parent[0]);
|
||||
}
|
||||
} elseif ($permit_mentions) {
|
||||
$allowed = true;
|
||||
|
@ -1850,7 +1822,7 @@ class Libzot
|
|||
}
|
||||
|
||||
if ($arr['mid'] !== $arr['parent_mid']) {
|
||||
if (perm_is_allowed($channel['channel_id'], $sender, 'moderated') && $relay) {
|
||||
if ((perm_is_allowed($channel['channel_id'], $sender, 'moderated') || $allowed === 'moderated') && $relay) {
|
||||
$arr['item_blocked'] = ITEM_MODERATED;
|
||||
}
|
||||
|
||||
|
@ -2035,7 +2007,6 @@ class Libzot
|
|||
|
||||
Activity::rewrite_mentions($arr);
|
||||
|
||||
|
||||
$maxlen = get_max_import_size();
|
||||
|
||||
if ($maxlen && mb_strlen($arr['body']) > $maxlen) {
|
||||
|
|
|
@ -1036,9 +1036,8 @@ function map_scope($scope, $strip = false) {
|
|||
return 'site: ' . App::get_hostname();
|
||||
case PERMS_PENDING:
|
||||
return 'any connections';
|
||||
// uncomment a few releases after the corresponding changes are made in can_comment_on_post. Here it was done on 2021-11-18
|
||||
// case PERMS_SPECIFIC:
|
||||
// return 'specific';
|
||||
case PERMS_SPECIFIC:
|
||||
return 'specific';
|
||||
case PERMS_CONTACTS:
|
||||
default:
|
||||
return 'contacts';
|
||||
|
|
Loading…
Reference in a new issue