Compare commits

...

3 commits

Author SHA1 Message Date
mrilyew
f1eddb4c9a fix(feed window): disable overflow 2025-04-02 23:00:50 +03:00
mrilyew
c5ad7bbbaa fix(bsdn): fix play button dynamic width 2025-04-02 22:57:43 +03:00
mrilyew
b58f416292 feat(club subs): sort by "target" (id) i. follower 2025-04-02 22:54:25 +03:00
6 changed files with 12 additions and 153 deletions

View file

@ -14,8 +14,7 @@ use openvk\Web\Models\Entities\{Topic, Comment, User, Photo, Video};
final class Board extends VKAPIRequestHandler
{
# 13/13
public function addTopic(int $group_id, string $title, string $text = "", bool $from_group = true, string $attachments = "")
public function addTopic(int $group_id, string $title, string $text = "", bool $from_group = true)
{
$this->requireUser();
$this->willExecuteWriteAction();
@ -23,15 +22,14 @@ final class Board extends VKAPIRequestHandler
$club = (new ClubsRepo())->get($group_id);
if (!$club) {
$this->fail(403, "Invalid club");
$this->fail(15, "Access denied");
}
if (!$club->canBeModifiedBy($this->getUser()) && !$club->isEveryoneCanCreateTopics()) {
$this->fail(403, "Access to club denied");
$this->fail(15, "Access denied");
}
$flags = 0;
if ($from_group == true && $club->canBeModifiedBy($this->getUser())) {
$flags |= 0b10000000;
}
@ -53,59 +51,6 @@ final class Board extends VKAPIRequestHandler
$comment->setCreated(time());
$comment->setFlags($flags);
$comment->save();
if (!empty($attachments)) {
$attachmentsArr = explode(",", $attachments);
# блин а мне это везде копировать типа
if (sizeof($attachmentsArr) > 10) {
$this->fail(50, "Error: too many attachments");
}
foreach ($attachmentsArr as $attac) {
$attachmentType = null;
if (str_contains($attac, "photo")) {
$attachmentType = "photo";
} elseif (str_contains($attac, "video")) {
$attachmentType = "video";
} else {
$this->fail(205, "Unknown attachment type");
}
$attachment = str_replace($attachmentType, "", $attac);
$attachmentOwner = (int) explode("_", $attachment)[0];
$attachmentId = (int) end(explode("_", $attachment));
$attacc = null;
if ($attachmentType == "photo") {
$attacc = (new PhotosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Photo does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this photo");
}
$comment->attach($attacc);
} elseif ($attachmentType == "video") {
$attacc = (new VideosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Video does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this video");
}
$comment->attach($attacc);
}
}
}
}
return $topic->getId();
@ -118,7 +63,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || !$topic->getClub() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -140,21 +85,15 @@ final class Board extends VKAPIRequestHandler
}
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || $topic->isDeleted() || $topic->isClosed()) {
$this->fail(100, "Topic is deleted, closed or invalid.");
$this->fail(15, "Access denied");
}
$flags = 0;
if ($from_group != 0 && !is_null($topic->getClub()) && $topic->getClub()->canBeModifiedBy($this->user)) {
$flags |= 0b10000000;
}
if (strlen($message) > 300) {
$this->fail(20, "Comment is too long.");
}
$comment = new Comment();
$comment->setOwner($this->getUser()->getId());
$comment->setModel(get_class($topic));
@ -164,74 +103,9 @@ final class Board extends VKAPIRequestHandler
$comment->setFlags($flags);
$comment->save();
if (!empty($attachments)) {
$attachmentsArr = explode(",", $attachments);
if (sizeof($attachmentsArr) > 10) {
$this->fail(50, "Error: too many attachments");
}
foreach ($attachmentsArr as $attac) {
$attachmentType = null;
if (str_contains($attac, "photo")) {
$attachmentType = "photo";
} elseif (str_contains($attac, "video")) {
$attachmentType = "video";
} else {
$this->fail(205, "Unknown attachment type");
}
$attachment = str_replace($attachmentType, "", $attac);
$attachmentOwner = (int) explode("_", $attachment)[0];
$attachmentId = (int) end(explode("_", $attachment));
$attacc = null;
if ($attachmentType == "photo") {
$attacc = (new PhotosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Photo does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this photo");
}
$comment->attach($attacc);
} elseif ($attachmentType == "video") {
$attacc = (new VideosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Video does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this video");
}
$comment->attach($attacc);
}
}
}
return $comment->getId();
}
public function deleteComment(int $comment_id, int $group_id = 0, int $topic_id = 0)
{
$this->requireUser();
$this->willExecuteWriteAction();
$comment = (new CommentsRepo())->get($comment_id);
if ($comment->isDeleted() || !$comment || !$comment->canBeDeletedBy($this->getUser())) {
$this->fail(403, "Access to comment denied");
}
$comment->delete();
return 1;
}
public function deleteTopic(int $group_id, int $topic_id)
{
$this->requireUser();
@ -248,25 +122,6 @@ final class Board extends VKAPIRequestHandler
return 1;
}
public function editComment(string $message, string $attachments, int $comment_id, int $group_id = 0, int $topic_id = 0)
{
# FIXME
/*
$this->requireUser();
$this->willExecuteWriteAction();
$comment = (new CommentsRepo)->get($comment_id);
if($comment->getOwner() != $this->getUser()->getId())
$this->fail(15, "Access to comment denied");
$comment->setContent($message);
$comment->setEdited(time());
$comment->save();
*/
return 1;
}
public function editTopic(int $group_id, int $topic_id, string $title)
{
$this->requireUser();

View file

@ -323,7 +323,7 @@ class Club extends RowModel
return sizeof($this->getFollowersQuery());
}
public function getFollowers(int $page = 1, int $perPage = 6, string $sort = "follower ASC"): \Traversable
public function getFollowers(int $page = 1, int $perPage = 6, string $sort = "target DESC"): \Traversable
{
$rels = $this->getFollowersQuery($sort)->page($page, $perPage);

View file

@ -99,6 +99,7 @@ button.bsdn_playButton {
padding-left: 0;
font-size: 22px;
cursor: pointer;
width: 22px;
}
.bsdn_fullScreenButton, .bsdn_repeatButton {

View file

@ -2919,7 +2919,6 @@ a.poll-retract-vote {
position: relative;
}
/* не говновёрстка, а пиксель-пёрфект) */
.page_header.search_expanded.search_expanded_at_all #search_and_one_more_wrapper {
width: 547px;
}

View file

@ -68,7 +68,7 @@ u(document).on('click', '#__feed_settings_link', (e) => {
`
MessageBox(tr("feed_settings"), body, [tr("close")], [Function.noop])
u('.ovk-diag-body').attr('style', 'padding:0px;height: 255px;')
u('.ovk-diag-body').attr('style', 'padding:0px;height: 255px;overflow: hidden;')
async function __switchTab(tab)
{

View file

@ -670,3 +670,7 @@ ul {
background: #1e1a2b;
border: 1px solid #403a56;
}
.ovk-modal-player-window #ovk-player-info {
background: #0e0b1a;
}