Merge pull request #10208 from MrPetovan/bug/10198-self-no-block-ignore

Prevent self block/ignore
This commit is contained in:
Tobias Diekershoff 2021-05-04 15:43:28 +02:00 committed by GitHub
commit 769834bf95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 320 additions and 300 deletions

View File

@ -888,7 +888,8 @@ function conversation_fetch_items(array $parent, array $items, array $condition,
return $items; return $items;
} }
function item_photo_menu($item) { function item_photo_menu($item)
{
$sub_link = ''; $sub_link = '';
$poke_link = ''; $poke_link = '';
$contact_url = ''; $contact_url = '';
@ -929,8 +930,8 @@ function item_photo_menu($item) {
if (!empty($pcid)) { if (!empty($pcid)) {
$contact_url = 'contact/' . $pcid; $contact_url = 'contact/' . $pcid;
$posts_link = $contact_url . '/posts'; $posts_link = $contact_url . '/posts';
$block_link = $contact_url . '/block'; $block_link = $item['self'] ? '' : $contact_url . '/block';
$ignore_link = $contact_url . '/ignore'; $ignore_link = $item['self'] ? '' : $contact_url . '/ignore';
} }
if ($cid && !$item['self']) { if ($cid && !$item['self']) {
@ -983,7 +984,7 @@ function item_photo_menu($item) {
if (strpos($v, 'javascript:') === 0) { if (strpos($v, 'javascript:') === 0) {
$v = substr($v, 11); $v = substr($v, 11);
$o .= '<li role="menuitem"><a onclick="' . $v . '">' . $k . '</a></li>' . PHP_EOL; $o .= '<li role="menuitem"><a onclick="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
} elseif ($v!='') { } elseif ($v) {
$o .= '<li role="menuitem"><a href="' . $v . '">' . $k . '</a></li>' . PHP_EOL; $o .= '<li role="menuitem"><a href="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
} }
} }

View File

@ -413,6 +413,10 @@ class Contact extends BaseModule
} }
if ($cmd === 'block') { if ($cmd === 'block') {
if (public_contact() === $contact_id) {
throw new BadRequestException(DI::l10n()->t('You can\'t block yourself'));
}
self::blockContact($contact_id); self::blockContact($contact_id);
$blocked = Model\Contact\User::isBlocked($contact_id, local_user()); $blocked = Model\Contact\User::isBlocked($contact_id, local_user());
@ -423,6 +427,10 @@ class Contact extends BaseModule
} }
if ($cmd === 'ignore') { if ($cmd === 'ignore') {
if (public_contact() === $contact_id) {
throw new BadRequestException(DI::l10n()->t('You can\'t ignore yourself'));
}
self::ignoreContact($contact_id); self::ignoreContact($contact_id);
$ignored = Model\Contact\User::isIgnored($contact_id, local_user()); $ignored = Model\Contact\User::isIgnored($contact_id, local_user());

View File

@ -223,9 +223,12 @@ class Post
$drop = [ $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
'pagedrop' => $item['pagedrop'], 'pagedrop' => $item['pagedrop'],
'select' => DI::l10n()->t('Select'), 'select' => DI::l10n()->t('Select'),
'delete' => $delete, 'delete' => $delete,
]; ];
}
if (!$item['self']) {
$block = [ $block = [
'blocking' => true, 'blocking' => true,
'block' => DI::l10n()->t('Block %s', $item['author-name']), 'block' => DI::l10n()->t('Block %s', $item['author-name']),

File diff suppressed because it is too large Load Diff