Compare commits

..

No commits in common. "eb81ed7a8213e7d49bb22710420189212ea41b1b" and "b80151583e7d1da3fffeed24d65e24dee65b8432" have entirely different histories.

5 changed files with 4 additions and 50 deletions

View file

@ -160,7 +160,6 @@ 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,8 +11,6 @@ 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 => {
@ -135,18 +133,6 @@ 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

@ -10,9 +10,8 @@ use Syokuhou\IConfig;
use Misuzu\{CSRF,Pagination,Perm,Template};
use Misuzu\Auth\AuthInfo;
use Misuzu\Parsers\Parser;
use Misuzu\Perms\Permissions;
use Misuzu\URLs\{URLInfo,URLRegistry};
use Misuzu\Users\{UsersContext,UserInfo};
use Misuzu\Users\UsersContext;
class MessagesRoutes extends RouteHandler {
public const FOLDER_META = [
@ -27,8 +26,7 @@ class MessagesRoutes extends RouteHandler {
private URLRegistry $urls,
private AuthInfo $authInfo,
private MessagesContext $msgsCtx,
private UsersContext $usersCtx,
private Permissions $perms
private UsersContext $usersCtx
) {}
private bool $canSendMessages;
@ -43,8 +41,7 @@ class MessagesRoutes extends RouteHandler {
if(!$globalPerms->check(Perm::G_MESSAGES_VIEW))
return 403;
$this->canSendMessages = $globalPerms->check(Perm::G_MESSAGES_SEND)
&& !$this->usersCtx->hasActiveBan($this->authInfo->getUserInfo());
$this->canSendMessages = $globalPerms->check(Perm::G_MESSAGES_SEND);
if($request->getMethod() === 'POST' && $request->isFormContent()) {
$content = $request->getContent();
@ -174,7 +171,6 @@ 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,
@ -251,19 +247,6 @@ class MessagesRoutes extends RouteHandler {
]);
}
private function checkCanReceiveMessages(UserInfo|string $userInfo): ?array {
$globalPerms = $this->perms->getPermissions('global', $userInfo);
if(!$globalPerms->check(Perm::G_MESSAGES_VIEW))
return [
'error' => [
'name' => 'msgs:recipient_cannot_recv',
'text' => 'This person is not allowed to receive messages.',
],
];
return null;
}
private function checkMessageFields(string $title, string $body, int $parser): ?array {
if(!Parser::isValid($parser))
return [
@ -365,10 +348,6 @@ class MessagesRoutes extends RouteHandler {
];
}
$error = $this->checkCanReceiveMessages($recipientInfo);
if($error !== null)
return $error;
$replyToInfo = null;
if(!empty($replyTo)) {
try {
@ -483,10 +462,6 @@ class MessagesRoutes extends RouteHandler {
],
];
$error = $this->checkCanReceiveMessages($messageInfo->getRecipientId());
if($error !== null)
return $error;
$sentAt = $draft ? null : time();
$msgsDb->updateMessage(

View file

@ -248,8 +248,7 @@ class MisuzuContext {
$this->urls,
$this->authInfo,
$this->messagesCtx,
$this->usersCtx,
$this->perms
$this->usersCtx
));
$routingCtx->register(new \Misuzu\Changelog\ChangelogRoutes(

View file

@ -40,11 +40,6 @@
<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>