Allow empty new-notice content via web if there's an upload
This commit is contained in:
parent
e69715005d
commit
03d2b680f8
@ -95,14 +95,29 @@ class NewnoticeAction extends FormAction
|
|||||||
{
|
{
|
||||||
assert($this->scoped instanceof Profile); // XXX: maybe an error instead...
|
assert($this->scoped instanceof Profile); // XXX: maybe an error instead...
|
||||||
$user = $this->scoped->getUser();
|
$user = $this->scoped->getUser();
|
||||||
$content = $this->trimmed('status_textarea');
|
$content = $this->formOpts['content'];
|
||||||
$options = array('source' => 'web');
|
$options = array('source' => 'web');
|
||||||
Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options));
|
Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options));
|
||||||
|
|
||||||
|
$upload = null;
|
||||||
|
try {
|
||||||
|
// throws exception on failure
|
||||||
|
$upload = MediaFile::fromUpload('attach', $this->scoped);
|
||||||
|
if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options))) {
|
||||||
|
$content .= ' ' . $upload->shortUrl();
|
||||||
|
}
|
||||||
|
Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
|
||||||
|
|
||||||
|
// 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
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
// TRANS: Client error displayed trying to send a notice without content.
|
// TRANS: Client error displayed trying to send a notice without content.
|
||||||
$this->clientError(_('No content!'));
|
$this->clientError(_('No content!'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$inter = new CommandInterpreter();
|
$inter = new CommandInterpreter();
|
||||||
|
|
||||||
@ -129,22 +144,6 @@ class NewnoticeAction extends FormAction
|
|||||||
$act->time = time();
|
$act->time = time();
|
||||||
$act->actor = $this->scoped->asActivityObject();
|
$act->actor = $this->scoped->asActivityObject();
|
||||||
|
|
||||||
$upload = null;
|
|
||||||
try {
|
|
||||||
// throws exception on failure
|
|
||||||
$upload = MediaFile::fromUpload('attach', $this->scoped);
|
|
||||||
if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options))) {
|
|
||||||
$content .= ' ' . $upload->shortUrl();
|
|
||||||
}
|
|
||||||
Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reject notice if it is too long (without the HTML)
|
// 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
|
// This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
|
||||||
if (Notice::contentTooLong($content)) {
|
if (Notice::contentTooLong($content)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user