feat: 국방, 임관메시지 에디터에 TipTap 적용
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetScoutMsg extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'msg',
|
||||
])->rule('lengthMax', 'msg', 1000);
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$msg = $this->args['msg'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||
$nationStor->scout_msg = WebUtil::htmlPurify($msg);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user