mirror of
https://github.com/openvk/openvk
synced 2024-11-13 10:39:24 +03:00
Wall: Handle exception when posting a long post
This commit is contained in:
parent
b5d1384d08
commit
6562884af2
1 changed files with 13 additions and 12 deletions
|
@ -184,9 +184,6 @@ final class WallPresenter extends OpenVKPresenter
|
|||
|
||||
if(!$canPost)
|
||||
$this->flashFail("err", "Ошибка доступа", "Вам нельзя писать на эту стену.");
|
||||
|
||||
if(false)
|
||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост слишком большой.");
|
||||
|
||||
$anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"];
|
||||
if($wallOwner instanceof Club && $this->postParam("as_group") === "on" && $this->postParam("force_sign") !== "on" && $anon) {
|
||||
|
@ -228,15 +225,19 @@ final class WallPresenter extends OpenVKPresenter
|
|||
if(empty($this->postParam("text")) && !$photo && !$video)
|
||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
||||
|
||||
$post = new Post;
|
||||
$post->setOwner($this->user->id);
|
||||
$post->setWall($wall);
|
||||
$post->setCreated(time());
|
||||
$post->setContent($this->postParam("text"));
|
||||
$post->setAnonymous($anon);
|
||||
$post->setFlags($flags);
|
||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||
$post->save();
|
||||
try {
|
||||
$post = new Post;
|
||||
$post->setOwner($this->user->id);
|
||||
$post->setWall($wall);
|
||||
$post->setCreated(time());
|
||||
$post->setContent($this->postParam("text"));
|
||||
$post->setAnonymous($anon);
|
||||
$post->setFlags($flags);
|
||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||
$post->save();
|
||||
} catch (\LengthException $ex) {
|
||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост слишком большой.");
|
||||
}
|
||||
|
||||
if(!is_null($photo))
|
||||
$post->attach($photo);
|
||||
|
|
Loading…
Reference in a new issue