forked from rDrama/rDrama
1
0
Fork 0

allow admins to unmute users from modmail

master
Aevann1 2022-10-24 22:38:54 +02:00
parent 10ba986957
commit 2d0879ec3e
2 changed files with 6 additions and 4 deletions

View File

@ -38,7 +38,7 @@ function approveComment(t,post_id,button1,button2,cls) {
} }
} }
function adminMuteUser(userId, muteStatus, buttonId) { function adminToggleMute(userId, muteStatus, buttonId) {
const xhr = createXhrWithFormKey(`/mute_user/${userId}/${muteStatus}`); const xhr = createXhrWithFormKey(`/mute_user/${userId}/${muteStatus}`);
xhr[0].onload = function() { xhr[0].onload = function() {
let data let data
@ -48,5 +48,6 @@ function adminMuteUser(userId, muteStatus, buttonId) {
showToast(success, getMessageFromJsonData(success, data)); showToast(success, getMessageFromJsonData(success, data));
}; };
xhr[0].send(xhr[1]); xhr[0].send(xhr[1]);
document.getElementById('mute-user-' + buttonId).classList.add("d-none"); document.getElementById('mute-user-' + buttonId).classList.toggle("d-none");
document.getElementById('unmute-user-' + buttonId).classList.toggle("d-none");
} }

View File

@ -561,8 +561,9 @@
</div> </div>
{% if request.path.startswith('/notifications') and c.level == 1 and c.sentto and not c.parent_submission and c.author_id != AUTOJANNY_ID %} {% if request.path.startswith('/notifications') and c.level == 1 and c.sentto and not c.parent_submission and c.author_id != AUTOJANNY_ID %}
{% if (v and v.admin_level >= PERMS['USER_BAN']) and (c.sentto == 2) and not c.author.is_muted %} {% if (v and v.admin_level >= PERMS['USER_BAN']) and (c.sentto == 2) %}
<a class="btn btn-primary mr-3" role="button" id="mute-user-{{c.id}}" onclick="adminMuteUser({{c.author_id}}, 1, {{c.id}})">Mute</a> <a class="btn btn-primary mr-3 {% if c.author.is_muted %}d-none{% endif %}" role="button" id="mute-user-{{c.id}}" onclick="adminToggleMute({{c.author_id}}, 1, {{c.id}})">Mute</a>
<a class="btn btn-primary mr-3 {% if not c.author.is_muted %}d-none{% endif %}" role="button" id="unmute-user-{{c.id}}" onclick="adminToggleMute({{c.author_id}}, 0, {{c.id}})">Unmute</a>
{% endif %} {% endif %}
<a class="btn btn-primary" role="button" onclick="ToggleReplyBox('reply-message-{{c.id}}')">Reply</a> <a class="btn btn-primary" role="button" onclick="ToggleReplyBox('reply-message-{{c.id}}')">Reply</a>