self-review

This commit is contained in:
mrilyew 2024-11-10 16:27:47 +03:00
parent 55bc872046
commit de937f65a1
7 changed files with 114 additions and 95 deletions

View file

@ -24,7 +24,7 @@ final class Video extends VKAPIRequestHandler
$items = []; $items = [];
$video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1])); $video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1]));
if($video) { if($video && !$video->isDeleted()) {
$out_video = $video->getApiStructure($this->getUser())->video; $out_video = $video->getApiStructure($this->getUser())->video;
$items[] = $out_video; $items[] = $out_video;
if($out_video['owner_id']) { if($out_video['owner_id']) {

View file

@ -1026,7 +1026,7 @@ final class Wall extends VKAPIRequestHandler
} }
} }
if(empty($message) && empty($attachments)) if(empty($message) && sizeof($final_attachments) < 1)
$this->fail(100, "Required parameter 'message' missing."); $this->fail(100, "Required parameter 'message' missing.");
if(!$comment || $comment->isDeleted()) if(!$comment || $comment->isDeleted())

View file

@ -366,7 +366,7 @@
</div> </div>
<div id="ajloader" class="loader"> <div id="ajloader" class="loader">
<img src="/assets/packages/static/openvk/img/loading_mini.gif" style="width: 40px;"> <img src="/assets/packages/static/openvk/img/loading_mini.gif">
</div> </div>
{include "components/cookies.xml"} {include "components/cookies.xml"}
@ -428,7 +428,7 @@
window.openvk = { window.openvk = {
"audio_genres": {\openvk\Web\Models\Entities\Audio::genres}, "audio_genres": {\openvk\Web\Models\Entities\Audio::genres},
"at_search": {$atSearch ?? false}, "at_search": {$atSearch ?? false},
"max_attachments": {\OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]}, "max_attachments": {\OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"] ?? 10},
"max_filesize_mb": 5, "max_filesize_mb": 5,
"current_id": {$thisUser ? $thisUser->getId() : 0}, "current_id": {$thisUser ? $thisUser->getId() : 0},
} }

View file

@ -111,6 +111,7 @@
</span> </span>
</div> </div>
</div> </div>
<div class='post-edit'></div>
<div n:if="!($compact ?? false)" class="post-menu"> <div n:if="!($compact ?? false)" class="post-menu">
{if is_null($thisUser)} {if is_null($thisUser)}
{var $forceNoDeleteLink = true} {var $forceNoDeleteLink = true}

View file

@ -727,7 +727,7 @@ u(document).on("click", "#editPost", async (e) => {
target.removeClass('lagged') target.removeClass('lagged')
edit_place.find('.edit_menu #__edit_save').on('click', async (e) => { edit_place.find('.edit_menu #__edit_save').on('click', async (ev) => {
const text_node = edit_place.find('.edit_menu textarea') const text_node = edit_place.find('.edit_menu textarea')
const nsfw_mark = edit_place.find(`.edit_menu input[name='nsfw']`) const nsfw_mark = edit_place.find(`.edit_menu input[name='nsfw']`)
const as_group = edit_place.find(`.edit_menu input[name='as_group']`) const as_group = edit_place.find(`.edit_menu input[name='as_group']`)
@ -756,7 +756,7 @@ u(document).on("click", "#editPost", async (e) => {
params['copyright'] = copyright.nodes[0].value params['copyright'] = copyright.nodes[0].value
} }
u(e.target).addClass('lagged') u(ev.target).addClass('lagged')
// больше двух запросов ! // больше двух запросов !
try { try {
if(type == 'post') { if(type == 'post') {
@ -767,16 +767,18 @@ u(document).on("click", "#editPost", async (e) => {
} }
} catch(e) { } catch(e) {
fastError(e.message) fastError(e.message)
u(e.target).removeClass('lagged') u(ev.target).removeClass('lagged')
return return
} }
const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}`, { const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}`, {
'method': 'POST' 'method': 'POST'
})).text() })).text()
u(e.target).removeClass('lagged') u(ev.target).removeClass('lagged')
post.removeClass('editing') post.removeClass('editing')
post.nodes[0].outerHTML = new_post_html post.nodes[0].outerHTML = new_post_html
bsdnHydrate()
}) })
edit_place.find('.edit_menu #__edit_cancel').on('click', (e) => { edit_place.find('.edit_menu #__edit_cancel').on('click', (e) => {
@ -1139,6 +1141,11 @@ u(document).on('click', '#__videoAttachment', async (e) => {
u("#gif_loader").remove() u("#gif_loader").remove()
const pages_count = Math.ceil(Number(videos.count) / per_page) const pages_count = Math.ceil(Number(videos.count) / per_page)
if(pages_count < 1) {
insert_place.append(query == '' ? tr('no_videos') : tr('no_videos_results'))
}
videos.items.forEach(video => { videos.items.forEach(video => {
const pretty_id = `${video.owner_id}_${video.id}` const pretty_id = `${video.owner_id}_${video.id}`
const is_attached = (form.find(`.upload-item[data-type='video'][data-id='${video.owner_id}_${video.id}']`)).length > 0 const is_attached = (form.find(`.upload-item[data-type='video'][data-id='${video.owner_id}_${video.id}']`)).length > 0
@ -1294,6 +1301,11 @@ u(document).on('click', '#__notesAttachment', async (e) => {
u("#gif_loader").remove() u("#gif_loader").remove()
const pages_count = Math.ceil(Number(notes.count) / per_page) const pages_count = Math.ceil(Number(notes.count) / per_page)
if(notes.count < 1) {
insert_place.append(tr('no_notes'))
}
notes.notes.forEach(note => { notes.notes.forEach(note => {
is_attached = (form.find(`.upload-item[data-type='note'][data-id='${note.owner_id}_${note.id}']`)).length > 0 is_attached = (form.find(`.upload-item[data-type='note'][data-id='${note.owner_id}_${note.id}']`)).length > 0
insert_place.append(` insert_place.append(`
@ -1583,7 +1595,10 @@ async function repost(id, repost_type = 'post') {
const repostsCount = u(`#repostsCount${id}`) const repostsCount = u(`#repostsCount${id}`)
const previousVal = repostsCount.length > 0 ? Number(repostsCount.html()) : 0; const previousVal = repostsCount.length > 0 ? Number(repostsCount.html()) : 0;
MessageBox(tr('share'), ` const msg = new CMessageBox({
title: tr('share'),
unique_name: 'repost_modal',
body: `
<div class='display_flex_column' style='gap: 1px;'> <div class='display_flex_column' style='gap: 1px;'>
<b>${tr('auditory')}</b> <b>${tr('auditory')}</b>
@ -1611,7 +1626,9 @@ async function repost(id, repost_type = 'post') {
<label><input type='checkbox' name="signed">${tr('add_signature')}</label> <label><input type='checkbox' name="signed">${tr('add_signature')}</label>
</div> </div>
</div> </div>
`, [tr('send'), tr('cancel')], [ `,
buttons: [tr('send'), tr('cancel')],
callbacks: [
async () => { async () => {
const message = u('#repostMsgInput').nodes[0].value const message = u('#repostMsgInput').nodes[0].value
const type = u(`input[name='repost_type']:checked`).nodes[0].value const type = u(`input[name='repost_type']:checked`).nodes[0].value
@ -1672,7 +1689,8 @@ async function repost(id, repost_type = 'post') {
} }
}, },
Function.noop Function.noop
]); ]
});
u('.ovk-diag-body').attr('style', 'padding: 14px;') u('.ovk-diag-body').attr('style', 'padding: 14px;')
u('.ovk-diag-body').on('change', `input[name='repost_type']`, (e) => { u('.ovk-diag-body').on('change', `input[name='repost_type']`, (e) => {

View file

@ -235,7 +235,7 @@ function ovk_is_ssl(): bool
function parseAttachments($attachments, array $allow_types = ['photo', 'video', 'note', 'audio']): array function parseAttachments($attachments, array $allow_types = ['photo', 'video', 'note', 'audio']): array
{ {
$exploded_attachments = is_array($attachments) ? $attachments : explode(",", $attachments); $exploded_attachments = is_array($attachments) ? $attachments : explode(",", $attachments);
$exploded_attachments = array_slice($exploded_attachments, 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]); $exploded_attachments = array_slice($exploded_attachments, 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"] ?? 10);
$imploded_types = implode('|', $allow_types); $imploded_types = implode('|', $allow_types);
$output_attachments = []; $output_attachments = [];
$repositories = [ $repositories = [