]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apimediaupload.php
Merge remote-tracking branch 'upstream/master'
[quix0rs-gnu-social.git] / actions / apimediaupload.php
index 8580b209a541893c0a699c32660a1ae2835dd751..c2b4a47b9a277d799acd799d5d1e2c4a597f22fb 100644 (file)
@@ -30,7 +30,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Upload an image via the API.  Returns a shortened URL for the image
- * to the user.
+ * to the user. Apparently modelled after a former Twitpic API.
  *
  * @category API
  * @package  StatusNet
@@ -88,9 +88,14 @@ class ApiMediaUploadAction extends ApiAuthAction
     function showResponse(MediaFile $upload)
     {
         $this->initDocument();
-        $this->elementStart('rsp', array('stat' => 'ok'));
+        $this->elementStart('rsp', array('stat' => 'ok', 'xmlns:atom'=>Activity::ATOM));
         $this->element('mediaid', null, $upload->fileRecord->id);
         $this->element('mediaurl', null, $upload->shortUrl());
+
+        $enclosure = $upload->fileRecord->getEnclosure();
+        $this->element('atom:link', array('rel'  => 'enclosure',
+                                          'href' => $enclosure->url,
+                                          'type' => $enclosure->mimetype));
         $this->elementEnd('rsp');
         $this->endDocument();
     }
@@ -100,7 +105,7 @@ class ApiMediaUploadAction extends ApiAuthAction
      *
      * @param String $msg an error message
      */
-    function clientError($msg)
+    function clientError($msg, $code=400, $format=null)
     {
         $this->initDocument();
         $this->elementStart('rsp', array('stat' => 'fail'));
@@ -111,5 +116,6 @@ class ApiMediaUploadAction extends ApiAuthAction
         $this->element('err', $errAttr, null);
         $this->elementEnd('rsp');
         $this->endDocument();
+        exit;
     }
 }