]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/api.php
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / lib / api.php
index 794b14050709dddb7d9503a3cad05b829a783cce..7d94eaee4eda1de4a8e7750106afc19e3afe262e 100644 (file)
@@ -288,17 +288,18 @@ class ApiAction extends Action
             $twitter_status['attachments'] = array();
 
             foreach ($attachments as $attachment) {
-                if ($attachment->isEnclosure()) {
+                $enclosure_o=$attachment->getEnclosure();
+                if ($enclosure_o) {
                     $enclosure = array();
-                    $enclosure['url'] = $attachment->url;
-                    $enclosure['mimetype'] = $attachment->mimetype;
-                    $enclosure['size'] = $attachment->size;
+                    $enclosure['url'] = $enclosure_o->url;
+                    $enclosure['mimetype'] = $enclosure_o->mimetype;
+                    $enclosure['size'] = $enclosure_o->size;
                     $twitter_status['attachments'][] = $enclosure;
                 }
             }
         }
 
-        if ($include_user) {
+        if ($include_user && $profile) {
             # Don't get notice (recursive!)
             $twitter_user = $this->twitterUserArray($profile, false);
             $twitter_status['user'] = $twitter_user;
@@ -1249,10 +1250,27 @@ class ApiAction extends Action
         case 'api':
             break;
         default:
+
+            $name = null;
+            $url  = null;
+
             $ns = Notice_source::staticGet($source);
+
             if ($ns) {
-                $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
+                $name = $ns->name;
+                $url  = $ns->url;
+            } else {
+                $app = Oauth_application::staticGet('name', $source);
+                if ($app) {
+                    $name = $app->name;
+                    $url  = $app->source_url;
+                }
+            }
+
+            if (!empty($name) && !empty($url)) {
+                $source_name = '<a href="' . $url . '">' . $name . '</a>';
             }
+
             break;
         }
         return $source_name;