]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / actions / newnotice.php
index 6e3720e09ecee566d1a95d0f3feed8a07c6582ef..9ee031f93636b0003f5ae6937c4bc9e892f64d48 100644 (file)
@@ -162,9 +162,10 @@ class NewnoticeAction extends Action
             $this->clientError(_('No content!'));
         } else {
             $content_shortened = common_shorten_links($content);
-            if (mb_strlen($content_shortened) > 140) {
-                $this->clientError(_('That\'s too long. '.
-                                     'Max notice size is 140 chars.'));
+            if (Notice::contentTooLong($content_shortened)) {
+                $this->clientError(sprintf(_('That\'s too long. '.
+                                             'Max notice size is %d chars.'),
+                                           Notice::maxContent()));
             }
         }
 
@@ -239,11 +240,16 @@ class NewnoticeAction extends Action
             $this->maybeAddRedir($fileRecord->id, $fileurl);
 
             $short_fileurl = common_shorten_url($fileurl);
+            if (!$short_fileurl) {
+                // todo -- Consider forcing default shortener if none selected?
+                $short_fileurl = $fileurl;
+            }
             $content_shortened .= ' ' . $short_fileurl;
 
-            if (mb_strlen($content_shortened) > 140) {
+            if (Notice::contentTooLong($content_shortened)) {
                 $this->deleteFile($filename);
-                $this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
+                $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'),
+                                           Notice::maxContent()));
             }
 
             // Also, not sure this is necessary -- Zach
@@ -253,13 +259,6 @@ class NewnoticeAction extends Action
         $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
                                   ($replyto == 'false') ? null : $replyto);
 
-        if (is_string($notice)) {
-            if (isset($filename)) {
-                $this->deleteFile($filename);
-            }
-            $this->clientError($notice);
-        }
-
         if (isset($mimetype)) {
             $this->attachFile($notice, $fileRecord);
         }