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
|
@ -184,9 +184,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) {
|
||||||
|
@ -228,15 +225,19 @@ 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", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
||||||
|
|
||||||
$post = new Post;
|
try {
|
||||||
$post->setOwner($this->user->id);
|
$post = new Post;
|
||||||
$post->setWall($wall);
|
$post->setOwner($this->user->id);
|
||||||
$post->setCreated(time());
|
$post->setWall($wall);
|
||||||
$post->setContent($this->postParam("text"));
|
$post->setCreated(time());
|
||||||
$post->setAnonymous($anon);
|
$post->setContent($this->postParam("text"));
|
||||||
$post->setFlags($flags);
|
$post->setAnonymous($anon);
|
||||||
$post->setNsfw($this->postParam("nsfw") === "on");
|
$post->setFlags($flags);
|
||||||
$post->save();
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
|
$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