mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +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
|
@ -185,9 +185,6 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
if(!$canPost)
|
if(!$canPost)
|
||||||
$this->flashFail("err", "Ошибка доступа", "Вам нельзя писать на эту стену.");
|
$this->flashFail("err", "Ошибка доступа", "Вам нельзя писать на эту стену.");
|
||||||
|
|
||||||
if(false)
|
|
||||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост слишком большой.");
|
|
||||||
|
|
||||||
$anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"];
|
$anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"];
|
||||||
if($wallOwner instanceof Club && $this->postParam("as_group") === "on" && $this->postParam("force_sign") !== "on" && $anon) {
|
if($wallOwner instanceof Club && $this->postParam("as_group") === "on" && $this->postParam("force_sign") !== "on" && $anon) {
|
||||||
$manager = $wallOwner->getManager($this->user->identity);
|
$manager = $wallOwner->getManager($this->user->identity);
|
||||||
|
@ -228,6 +225,7 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
if(empty($this->postParam("text")) && !$photo && !$video)
|
if(empty($this->postParam("text")) && !$photo && !$video)
|
||||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
$this->flashFail("err", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
||||||
|
|
||||||
|
try {
|
||||||
$post = new Post;
|
$post = new Post;
|
||||||
$post->setOwner($this->user->id);
|
$post->setOwner($this->user->id);
|
||||||
$post->setWall($wall);
|
$post->setWall($wall);
|
||||||
|
@ -237,6 +235,9 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$post->setFlags($flags);
|
$post->setFlags($flags);
|
||||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
$post->save();
|
$post->save();
|
||||||
|
} catch (\LengthException $ex) {
|
||||||
|
$this->flashFail("err", "Не удалось опубликовать пост", "Пост слишком большой.");
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_null($photo))
|
if(!is_null($photo))
|
||||||
$post->attach($photo);
|
$post->attach($photo);
|
||||||
|
|
Loading…
Reference in a new issue