]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesupdate.php
Merge branch 'fixes/private_scope_on_tags' into social-master
[quix0rs-gnu-social.git] / actions / apistatusesupdate.php
index 73b87cac988de4f596433441fe6d5819ddb3b9f8..6b876c8f117a045b33f70d1a910443c63d5a1a91 100644 (file)
@@ -245,24 +245,19 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             }
 
             $upload = null;
-
             try {
                 $upload = MediaFile::fromUpload('media', $this->scoped);
-            } catch (Exception $e) {
-                $this->clientError($e->getMessage(), $e->getCode());
-            }
-
-            if (isset($upload)) {
                 $this->status .= ' ' . $upload->shortUrl();
-
                 /* Do not call shortenlinks until the whole notice has been build */
+            } catch (NoUploadedMediaException $e) {
+                // There was no uploaded media for us today.
             }
 
             /* Do call shortenlinks here & check notice length since notice is about to be saved & sent */
             $status_shortened = $this->auth_user->shortenlinks($this->status);
 
             if (Notice::contentTooLong($status_shortened)) {
-                if (isset($upload)) {
+                if ($upload instanceof MediaFile) {
                     $upload->delete();
                 }
                 // TRANS: Client error displayed exceeding the maximum notice length.
@@ -336,13 +331,15 @@ class ApiStatusesUpdateAction extends ApiAuthAction
      */
     function supported($cmd)
     {
-        static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
-            'FavCommand', 'OnCommand', 'OffCommand', 'JoinCommand', 'LeaveCommand');
+        static $cmdlist = array('SubCommand', 'UnsubCommand',
+            'OnCommand', 'OffCommand', 'JoinCommand', 'LeaveCommand');
+
+        $supported = null;
 
-        if (in_array(get_class($cmd), $cmdlist)) {
-            return true;
+        if (Event::handle('CommandSupportedAPI', array($cmd, &$supported))) {
+            $supported = $supported || in_array(get_class($cmd), $cmdlist);
         }
 
-        return false;
+        return $supported;
     }
 }