$act->time = time();
$act->actor = $this->scoped->asActivityObject();
- $content = $this->scoped->shortenLinks($content);
-
$upload = null;
try {
// throws exception on failure
}
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
}
- $actobj = new ActivityObject();
- $actobj->type = ActivityObject::NOTE;
- $actobj->content = common_render_content($content, $this->scoped, $parent);
-
- $act->objects[] = $actobj;
-
+ // 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()));
+ }
$act->context = new ActivityContext();
$act->context->location = Location::fromOptions($locOptions);
}
- $author_id = $this->scoped->id;
- $text = $content;
+ $content = $this->scoped->shortenLinks($content);
- // Does the heavy-lifting for getting "To:" information
+ // FIXME: Make sure NoticeTitle plugin gets a change to add the title to our activityobject!
+ if (Event::handle('StartNoticeSaveWeb', array($this, $this->scoped, &$content, &$options))) {
- ToSelector::fillOptions($this, $options);
+ // FIXME: We should be able to get the attentions from common_render_content!
+ // and maybe even directly save whether they're local or not!
+ $act->context->attention = common_get_attentions($content, $this->scoped, $parent);
- // FIXME: Make sure NoticeTitle plugin gets a change to add the title to our activityobject!
- if (Event::handle('StartNoticeSaveWeb', array($this, &$author_id, &$text, &$options))) {
+ $actobj = new ActivityObject();
+ $actobj->type = ActivityObject::NOTE;
+ $actobj->content = common_render_content($content, $this->scoped, $parent);
+
+ // Finally add the activity object to our activity
+ $act->objects[] = $actobj;
$this->stored = Notice::saveActivity($act, $this->scoped, $options);