]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/postnotice.php
add inboxed and regenerate data objects
[quix0rs-gnu-social.git] / actions / postnotice.php
index 3b5a4ee1536264ad24da69956fd0128838d27187..243aa31633f172ef62b16a7ffe1d59ba99b9d723 100644 (file)
@@ -21,14 +21,11 @@ if (!defined('LACONICA')) { exit(1); }
 
 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();
@@ -61,10 +58,13 @@ class PostnoticeAction extends Action {
                        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)) {
@@ -78,22 +78,11 @@ class PostnoticeAction extends Action {
                }
                $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;