X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnewnotice.php;h=4a864b25c3c926e2b2964c4892484096d69fb58e;hb=1f02dc639ec3dfa44df87c4fa031b3f298ffee7e;hp=17499312fbcbd45ea1157cba0e6a87010d468d5a;hpb=95d415257a43d5d4338ce22089463c1820b6bf8b;p=quix0rs-gnu-social.git diff --git a/actions/newnotice.php b/actions/newnotice.php index 17499312fb..4a864b25c3 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -129,8 +129,6 @@ class NewnoticeAction extends FormAction $act->time = time(); $act->actor = $this->scoped->asActivityObject(); - $content = $this->scoped->shortenLinks($content); - $upload = null; try { // throws exception on failure @@ -140,21 +138,26 @@ class NewnoticeAction extends FormAction } Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options)); - if (Notice::contentTooLong($content)) { - $upload->delete(); - // TRANS: Client error displayed exceeding the maximum notice length. - // TRANS: %d is the maximum length for a notice. - $this->clientError(sprintf(_m('Maximum notice size is %d character, including attachment URL.', - 'Maximum notice size is %d characters, including attachment URL.', - Notice::maxContent()), - Notice::maxContent())); - } + // We could check content length here if the URL was added, but I'll just let it slide for now... $act->enclosures[] = $upload->getEnclosure(); } catch (NoUploadedMediaException $e) { // simply no attached media to the new notice } + $content = $this->scoped->shortenLinks($content); + + // Reject notice if it is too long (without the HTML) + // This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction + if (Notice::contentTooLong($content)) { + // TRANS: Client error displayed when the parameter "status" is missing. + // TRANS: %d is the maximum number of character for a notice. + throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.', + 'That\'s too long. Maximum notice size is %d characters.', + Notice::maxContent()), + Notice::maxContent())); + } + $actobj = new ActivityObject(); $actobj->type = ActivityObject::NOTE; $actobj->content = common_render_content($content, $this->scoped, $parent);