diff --git a/Web/Presenters/templates/Wall/Post.xml b/Web/Presenters/templates/Wall/Post.xml index 3d136ebd..2e08f70f 100644 --- a/Web/Presenters/templates/Wall/Post.xml +++ b/Web/Presenters/templates/Wall/Post.xml @@ -56,29 +56,6 @@ > {_changes_history} - {_report} + {_report} - {/block} diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index b39b8239..7f20f31b 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -58,6 +58,7 @@ {_pinned} + {if $canBePinned && !($forceNoPinLink ?? false) && $compact == false} {if $post->isPinned()} diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 3612aa1d..bece0c51 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -133,8 +133,16 @@ {if !($forceNoDeleteLink ?? false) && $canBeDeleted} {_delete}  |  + {/if} + + {if $feedIgnoreButton && !$canBeDeleted} + {_feed_ignore}  |  {/if} - + + {if !$canBeDeleted} + {_report}  |  + {/if} + {if !($forceNoPinLink ?? false) && $canBePinned} {if $post->isPinned()} {_unpin} diff --git a/Web/static/css/microblog.css b/Web/static/css/microblog.css index 503af42a..46a1bb04 100644 --- a/Web/static/css/microblog.css +++ b/Web/static/css/microblog.css @@ -86,6 +86,20 @@ background-color: rgb(240, 240, 240); } +.report { + float: right; + height: 16px; + width: 16px; + overflow: auto; + background: url("/assets/packages/static/openvk/img/report.png") no-repeat 0 0; + opacity: 0.1; + transition-duration: 0.3s; +} + +.report:hover { + opacity: 0.4; +} + .post-author .delete { float: right; height: 16px; diff --git a/Web/static/img/report.png b/Web/static/img/report.png new file mode 100644 index 00000000..7bd1b9ee Binary files /dev/null and b/Web/static/img/report.png differ diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index 66eeddf1..14fb2385 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -43,6 +43,53 @@ u(document).on("click", "#__ignoreSomeone", async (e) => { } }) +u(document).on("click", "#__ignoreSomeoneFeed", async (e) => { + e.preventDefault() + + const TARGET = u(e.target) + const ENTITY_ID = Number(e.target.dataset.id) + const VAL = Number(e.target.dataset.val) + const ACT = VAL == 1 ? 'ignore' : 'unignore' + const METHOD_NAME = ACT == 'ignore' ? 'addBan' : 'deleteBan' + const PARAM_NAME = ENTITY_ID < 0 ? 'group_ids' : 'user_ids' + const ENTITY_NAME = ENTITY_ID < 0 ? 'club' : 'user' + const URL = `/method/newsfeed.${METHOD_NAME}?auth_mechanism=roaming&${PARAM_NAME}=${Math.abs(ENTITY_ID)}` + + TARGET.closest('.post').addClass('lagged') + const REQ = await fetch(URL) + const RES = await REQ.json() + TARGET.closest('.post').removeClass('lagged') + + if(RES.error_code) { + switch(RES.error_code) { + case -10: + fastError(';/') + break + case -50: + fastError(tr('ignored_sources_limit')) + break + default: + fastError(res.error_msg) + break + } + return + } + + if(RES.response == 1) { + if(ACT == 'unignore') { + TARGET.closest('.scroll_node').find('.post').removeClass('post-hidden'); + TARGET.closest('.ignore-message').remove() + } else { + TARGET.closest('.post').addClass('post-hidden'); + TARGET.closest('.scroll_node').append(` +
+ ${tr(`feed_${ENTITY_NAME}_ignored`)} ${tr('feed_unignore')} +
+ `) + } + } +}) + u(document).on('click', '#__feed_settings_link', (e) => { e.preventDefault() @@ -306,3 +353,26 @@ function openJsSettings() { `) } + + +function reportPost(postId) { + uReportMsgTxt = tr("going_to_report_post"); + uReportMsgTxt += "
"+tr("report_question_text"); + uReportMsgTxt += "

"+tr("report_reason")+": " + + MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [ + (function() { + res = document.querySelector("#uReportMsgInput").value; + xhr = new XMLHttpRequest(); + xhr.open("GET", "/report/" + postId + "?reason=" + res + "&type=post", true); + xhr.onload = (function() { + if(xhr.responseText.indexOf("reason") === -1) + MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]); + else + MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]); + }); + xhr.send(null); + }), + Function.noop + ]); + } \ No newline at end of file