remove all

This commit is contained in:
mrilyew 2024-12-11 16:56:21 +03:00
parent 75ef7eaec6
commit 7f86096b65
13 changed files with 22 additions and 216 deletions

View file

@ -2,7 +2,7 @@
namespace openvk\VKAPI\Handlers;
use openvk\Web\Models\Entities\{User, Report};
use openvk\Web\Models\Repositories\Users as UsersRepo;
use openvk\Web\Models\Repositories\{Photos, Clubs, Albums, Videos, Notes, Audios, Blacklists};
use openvk\Web\Models\Repositories\{Photos, Clubs, Albums, Videos, Notes, Audios};
use openvk\Web\Models\Repositories\Reports;
final class Users extends VKAPIRequestHandler
@ -52,8 +52,8 @@ final class Users extends VKAPIRequestHandler
"last_name" => $usr->getLastName(true),
"is_closed" => $usr->isClosed(),
"can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()),
"blacklisted" => (new Blacklists)->isBanned($usr, $authuser),
"blacklisted_by_me" => (new Blacklists)->isBanned($authuser, $usr)
"blacklisted" => false,
"blacklisted_by_me" => false,
];
$flds = explode(',', $fields);
@ -271,7 +271,6 @@ final class Users extends VKAPIRequestHandler
}
}
if (!(new Blacklists)->isBanned($usr, $authuser))
if($usr->getOnline()->timestamp() + 300 > time())
$response[$i]->online = 1;
else
@ -309,7 +308,7 @@ final class Users extends VKAPIRequestHandler
$response = $this->get(implode(',', $followers), $fields, 0, $count);
return (object) [
"count" => $target->getFollowersCount(),
"count" => $users->get($user_id)->getFollowersCount(),
"items" => $response
];
}

View file

@ -1,31 +0,0 @@
<?php declare(strict_types=1);
namespace openvk\Web\Models\Entities;
use openvk\Web\Models\RowModel;
use openvk\Web\Util\DateTime;
use openvk\Web\Models\Entities\{User, Manager};
use openvk\Web\Models\Repositories\{Users, Clubs};
class BlacklistItem extends RowModel
{
protected $tableName = "blacklists";
function getId(): int
{
return $this->getRecord()->index;
}
function getAuthor(): ?User
{
return (new Users)->get($this->getRecord()->author);
}
function getTarget(): ?User
{
return (new Users)->get($this->getRecord()->target);
}
function getCreationDate(): DateTime
{
return new DateTime($this->getRecord()->created);
}
}

View file

@ -5,7 +5,7 @@ use openvk\Web\Themes\{Themepack, Themepacks};
use openvk\Web\Util\DateTime;
use openvk\Web\Models\RowModel;
use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift, Audio};
use openvk\Web\Models\Repositories\{Applications, Bans, Comments, Notes, Posts, Users, Clubs, Albums, Gifts, Notifications, Videos, Photos, Blacklists};
use openvk\Web\Models\Repositories\{Applications, Bans, Comments, Notes, Posts, Users, Clubs, Albums, Gifts, Notifications, Videos, Photos};
use openvk\Web\Models\Exceptions\InvalidUserNameException;
use Nette\Database\Table\ActiveRow;
use Chandler\Database\DatabaseConnection;
@ -510,7 +510,7 @@ class User extends RowModel
return $permStatus === User::PRIVACY_EVERYONE;
else if($user->getId() === $this->getId())
return true;
else if ((new Blacklists)->isBanned($this, $user)) {
else if ($this->isBlacklistedBy($user)) {
return $user->isAdmin() && !OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["blacklists"]["applyToAdmins"];
}
@ -1494,6 +1494,11 @@ class User extends RowModel
return DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId())->count();
}
function isBlacklistedBy($user): bool
{
return false;
}
use Traits\TBackDrops;
use Traits\TSubscribable;
use Traits\TAudioStatuses;

View file

@ -1,46 +0,0 @@
<?php declare(strict_types=1);
namespace openvk\Web\Models\Repositories;
use openvk\Web\Models\Entities\{User, BlacklistItem};
use openvk\Web\Models\Repositories\{Clubs, Users};
use Nette\Database\Table\ActiveRow;
use Chandler\Database\DatabaseConnection as DB;
class Blacklists
{
private $context;
private $blacklists;
function __construct()
{
$this->context = DB::i()->getContext();
$this->blacklists = $this->context->table("blacklists");
}
function getList(User $user, $page = 1): \Traversable
{
foreach($this->blacklists->where("author", $user->getId())->order("created DESC")->page($page, 10) as $blacklistItem)
yield new BlacklistItem($blacklistItem);
}
function getByAuthorAndTarget(int $author, int $target): ?BlacklistItem
{
$fetch = $this->blacklists->where(["author" => $author, "target" => $target])->fetch();
if ($fetch)
return new BlacklistItem($fetch);
else
return null;
}
function getCount(User $user): int
{
return sizeof($this->blacklists->where("author", $user->getId())->fetch());
}
function isBanned(User $author, User $target): bool
{
if (!$author || !$target)
return FALSE;
return !is_null($this->getByAuthorAndTarget($author->getId(), $target->getId()));
}
}

View file

@ -1,43 +0,0 @@
<?php declare(strict_types=1);
namespace openvk\Web\Presenters;
use openvk\Web\Models\Entities\{BlacklistItem};
use openvk\Web\Models\Repositories\{Blacklists, Users};
use Chandler\Database\DatabaseConnection as DB;
final class BlacklistPresenter extends OpenVKPresenter
{
private $blacklists;
function __construct(Blacklists $blacklists)
{
$this->blacklists = $blacklists;
}
function renderAddToBlacklist(): void
{
$this->willExecuteWriteAction();
$this->assertUserLoggedIn();
$record = new BlacklistItem;
$target = (new Users)->get((int) $this->postParam("id"));
$record->setAuthor($this->user->identity->getId());
$record->setTarget($this->postParam("id"));
$record->setCreated(time());
$record->save();
$this->flashFail("succ", tr("success"), tr("user_blacklisted", $target->getCanonicalName()));
}
function renderRemoveFromBlacklist(): void
{
$this->willExecuteWriteAction();
$this->assertUserLoggedIn();
$record = $this->blacklists->getByAuthorAndTarget($this->user->identity->getId(), $this->postParam("id"));
$name = $record->getTarget()->getCanonicalName();
$record->delete(false);
$this->flashFail("succ", tr("success"), tr("user_removed_from_the_blacklist", $name));
}
}

View file

@ -1,7 +1,7 @@
<?php declare(strict_types=1);
namespace openvk\Web\Presenters;
use openvk\Web\Models\Entities\{Club, Photo, Album, User};
use openvk\Web\Models\Repositories\{Photos, Albums, Users, Clubs, Blacklists};
use openvk\Web\Models\Repositories\{Photos, Albums, Users, Clubs};
use Nette\InvalidStateException as ISE;
final class PhotosPresenter extends OpenVKPresenter

View file

@ -5,7 +5,7 @@ use openvk\Web\Util\Sms;
use openvk\Web\Themes\Themepacks;
use openvk\Web\Models\Entities\{Photo, Post, EmailChangeVerification};
use openvk\Web\Models\Entities\Notifications\{CoinsTransferNotification, RatingUpNotification};
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Videos, Notes, Vouchers, EmailChangeVerifications, Audios, Blacklists};
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Videos, Notes, Vouchers, EmailChangeVerifications, Audios};
use openvk\Web\Models\Exceptions\InvalidUserNameException;
use openvk\Web\Util\Validator;
use Chandler\Security\Authenticator;
@ -15,15 +15,13 @@ use Nette\Database\UniqueConstraintViolationException;
final class UserPresenter extends OpenVKPresenter
{
private $users;
public $deactivationTolerant = false;
protected $presenterName = "user";
private $users;
private $blacklists;
function __construct(Users $users, Blacklists $blacklists)
function __construct(Users $users)
{
$this->users = $users;
$this->blacklists = $blacklists;
parent::__construct();
}
@ -581,7 +579,7 @@ final class UserPresenter extends OpenVKPresenter
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
}
$this->template->mode = in_array($this->queryParam("act"), [
"main", "security", "privacy", "finance", "finance.top-up", "interface", "blacklist"
"main", "security", "privacy", "finance", "finance.top-up", "interface"
]) ? $this->queryParam("act")
: "main";
@ -596,11 +594,6 @@ final class UserPresenter extends OpenVKPresenter
$this->template->qrCodeData = $qrCode[1];
}
if($this->template->mode == "blacklist") {
$this->template->items = $this->blacklists->getList($user);
$this->template->count = $this->blacklists->getCount($user);
}
$this->template->user = $user;
$this->template->themes = Themepacks::i()->getThemeList();
}

View file

@ -1,7 +1,7 @@
<?php declare(strict_types=1);
namespace openvk\Web\Presenters;
use openvk\Web\Models\Entities\Video;
use openvk\Web\Models\Repositories\{Users, Videos, Blacklists};
use openvk\Web\Models\Repositories\{Users, Videos};
use Nette\InvalidStateException as ISE;
final class VideosPresenter extends OpenVKPresenter

View file

@ -13,7 +13,6 @@
{var $isFinance = $mode === 'finance'}
{var $isFinanceTU = $mode === 'finance.top-up'}
{var $isInterface = $mode === 'interface'}
{var $isBlackList = $mode === 'blacklist'}
<div class="tabs">
<div n:attr="id => ($isMain ? 'activetabs' : 'ki')" class="tab">
@ -31,9 +30,6 @@
<div n:attr="id => ($isInterface ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($isInterface ? 'act_tab_a' : 'ki')" href="/settings?act=interface">{_interface}</a>
</div>
<div n:attr="id => ($isBlackList ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($isBlackList ? 'act_tab_a' : 'ki')" href="/settings?act=blacklist">{_blacklist}</a>
</div>
</div>
<div class="container_gray">
@ -717,49 +713,6 @@
</tbody>
</table>
</form>
{elseif $isBlackList}
{if $count < 1}
{include "../components/nothing.xml"}
{/if}
<div n:foreach="$items as $item" class="content">
<table>
<tbody>
<tr>
<td valign="top">
<a href="/id2">
<img src="{$item->getTarget()->getAvatarURL()}" width="75" alt="Фотография пользователя">
</a>
</td>
<td valign="top" style="width: 100%">
<a href="/id2">
<b>
{$item->getTarget()->getCanonicalName()}
<img n:if="$item->getTarget()->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
</b>
</a>
<br>
<table>
<tbody>
<tr>
<td width="120" valign="top"><span class="nobold">Дата добавления:</span></td>
<td>{$item->getCreationDate()}</td>
</tr>
</tbody>
</table>
</td>
<td valign="top" class="action_links" style="width: 150px;">
<form action="/removeFromBl" method="post" class="profile_link_form">
<input type="hidden" name="act" value="rem">
<input type="hidden" name="id" value="{$item->getTarget()->getId()}">
<input type="hidden" name="hash" value="{$csrfToken}">
<input type="submit" class="profile_link" value="удалить из чёрного списка">
</form>
</td>
</tr>
</tbody>
</table>
</div>
{/if}
</div>

View file

@ -171,19 +171,6 @@
</a>
{/if}
<a style="width: 194px;" n:if="$user->getFollowersCount() > 0" href="/friends{$user->getId()}?act=incoming" class="profile_link">{tr("followers", $user->getFollowersCount())}</a>
{if $isBlacklistedThem}
<form n:if="$thisUser->getId() != $user->getId()" action="/removeFromBl" method="post" class="profile_link_form">
<input type="hidden" name="id" value="{$user->getId()}" />
<input type="hidden" name="hash" value="{$csrfToken}" />
<input type="submit" class="profile_link" value="Удалить из чёрного списка" />
</form>
{else}
<form n:if="$thisUser->getId() != $user->getId()" action="/addToBl" method="post" class="profile_link_form">
<input type="hidden" name="id" value="{$user->getId()}" />
<input type="hidden" name="hash" value="{$csrfToken}" />
<input type="submit" class="profile_link" value="Добавить в чёрный список" />
</form>
{/if}
</div>
<div n:if="isset($thisUser) && !$thisUser->prefersNotToSeeRating()" class="profile-hints">
{var $completeness = $user->getProfileCompletenessReport()}
@ -399,11 +386,6 @@
<div class="right_big_block">
<div class="page_info">
<div n:if="$isBlacklistedByThem AND $thisUser->isAdmin() AND $thisUser->getId() !== $user->getId()" class="user-alert">
<b>{_admin_privacy_warning}:</b>
<br/>
{_user_blacklisted_you}
</div>
<div n:if="!is_null($alert = $user->getAlert())" class="user-alert">{strpos($alert, "@") === 0 ? tr(substr($alert, 1)) : $alert}</div>
{var $thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()}
<div n:if="$thatIsThisUser" class="page_status_popup" id="status_editor" style="display: none;">

View file

@ -25,7 +25,6 @@ services:
- openvk\Web\Presenters\AppsPresenter
- openvk\Web\Presenters\ThemepacksPresenter
- openvk\Web\Presenters\VKAPIPresenter
- openvk\Web\Presenters\BlacklistPresenter
- openvk\Web\Presenters\PollPresenter
- openvk\Web\Presenters\BannedLinkPresenter
- openvk\Web\Models\Repositories\Users
@ -50,7 +49,6 @@ services:
- openvk\Web\Models\Repositories\Topics
- openvk\Web\Models\Repositories\Applications
- openvk\Web\Models\Repositories\ContentSearchRepository
- openvk\Web\Models\Repositories\Blacklists
- openvk\Web\Models\Repositories\Aliases
- openvk\Web\Models\Repositories\BannedLinks
- openvk\Web\Models\Repositories\ChandlerGroups

View file

@ -107,10 +107,6 @@ routes:
handler: "Group->sub"
- url: "/setSub/v4/club"
handler: "Group->attend"
- url: "/removeFromBl"
handler: "Blacklist->removeFromBlacklist"
- url: "/addToBl"
handler: "Blacklist->addToBlacklist"
- url: "/groups/{num}/setNewOwner/{num}"
handler: "Group->changeOwner"
- url: "/comment{num}/like"

View file

@ -1,4 +1,4 @@
CREATE TABLE `blacklists` (
CREATE TABLE `blacklist_relations` (
`index` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`author` BIGINT UNSIGNED NOT NULL,
`target` BIGINT UNSIGNED NOT NULL,