Added notice when recipient is banned.

This commit is contained in:
flash 2024-02-02 02:16:37 +00:00
parent 8ef11afe02
commit eb81ed7a82
4 changed files with 21 additions and 0 deletions

View file

@ -160,6 +160,7 @@ const MszMessages = () => {
if(msgsRecipient !== undefined)
msgsRecipient.onUpdate(async info => {
msgsReply.setRecipient(typeof info.id === 'string' ? info.id : '');
msgsReply.setWarning(info.ban ? `${(typeof info.name === 'string' ? info.name : 'This user')} has been banned and will be unable to respond to your messages.` : undefined);
});
msgsReply.onSubmit(async form => {

View file

@ -11,6 +11,8 @@ const MszMessagesReply = function(element) {
const parserSelect = form.querySelector('.js-messages-reply-parser');
const saveBtn = form.querySelector('.js-messages-reply-save');
const sendBtn = form.querySelector('.js-messages-reply-send');
const warnElem = form.querySelector('.js-reply-form-warning');
const warnText = warnElem instanceof Element ? warnElem.querySelector('.js-reply-form-warning-text') : undefined;
let submitHandler;
form.addEventListener('submit', ev => {
@ -133,6 +135,18 @@ const MszMessagesReply = function(element) {
return {
getElement: () => element,
setWarning: text => {
if(warnElem === undefined || warnText === undefined)
return;
if(text === undefined) {
warnElem.hidden = true;
warnText.textContent = '';
} else {
warnElem.hidden = false;
warnText.textContent = text;
}
},
setRecipient: userId => {
for(const field of form.elements)
if(field.name === 'recipient') {

View file

@ -174,6 +174,7 @@ class MessagesRoutes extends RouteHandler {
return [
'id' => $userInfo->getId(),
'name' => $userInfo->getName(),
'ban' => $this->usersCtx->hasActiveBan($userInfo),
'avatar' => $this->urls->format('user-avatar', [
'user' => $userInfo->getId(),
'res' => 200,

View file

@ -40,6 +40,11 @@
<form class="messages-reply-form js-messages-reply-form">
{{ input_hidden('recipient', '') }}
<div class="warning js-reply-form-warning" hidden>
<div class="warning__content">
<p class="js-reply-form-warning-text"></p>
</div>
</div>
<div class="messages-reply-subject">
{{ input_text('title', 'messages-reply-subject-input', '', 'text', 'Subject', true) }}
</div>