require_once(INSTALLDIR.'/lib/omb.php');
-function is_readonly() {
- return false;
-}
-
class PostnoticeAction extends Action {
function handle($args) {
parent::handle($args);
try {
+ common_remove_magic_from_request();
$req = OAuthRequest::from_request();
# Note: server-to-server function!
$server = omb_oauth_server();
return false;
}
$content = $req->get_parameter('omb_notice_content');
- if (!$content || strlen($content) > 140) {
- common_user_error(_('Invalid notice content'), 400);
- return false;
- }
+// if (!$content || strlen($content) > 140) {
+ $content = common_shorten_links($content);
+ if (mb_strlen($content) > 140) {
+ common_user_error(_('Invalid notice content'), 400);
+ return false;
+ }
+// }
$notice_uri = $req->get_parameter('omb_notice');
if (!Validate::uri($notice_uri) &&
!common_valid_tag($notice_uri)) {
}
$notice = Notice::staticGet('uri', $notice_uri);
if (!$notice) {
- $notice = new Notice();
- $notice->is_local = 0;
- $notice->profile_id = $remote_profile->id;
- $notice->uri = $notice_uri;
- $notice->content = $content;
- $notice->rendered = common_render_content($notice->content, $notice);
- if ($notice_url) {
- $notice->url = $notice_url;
- }
- $notice->created = DB_DataObject_Cast::dateTime(); # current time
- $id = $notice->insert();
- if (!$id) {
- common_server_error(_('Error inserting notice'), 500);
+ $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, 0, $notice_uri);
+ if (is_string($notice)) {
+ common_server_serror($notice, 500);
return false;
}
- common_save_replies($notice);
common_broadcast_notice($notice, true);
}
return true;