]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add xmlns:statusnet and statusnet:notice_info element to Atom entries for notices
authorZach Copley <zach@status.net>
Thu, 6 May 2010 05:35:16 +0000 (22:35 -0700)
committerZach Copley <zach@status.net>
Thu, 6 May 2010 21:48:11 +0000 (21:48 +0000)
classes/Notice.php
lib/atomnoticefeed.php

index c0828674d17e5643b514316992644a5728e0a8a6..e82a8252687752f8ec19715c2d4ffcc6d009e45a 100644 (file)
@@ -1172,7 +1172,7 @@ class Notice extends Memcached_DataObject
         return $groups;
     }
 
-    function asAtomEntry($namespace=false, $source=false, $author=true)
+    function asAtomEntry($namespace=false, $source=false, $author=true, $cur=null)
     {
         $profile = $this->getProfile();
 
@@ -1185,7 +1185,8 @@ class Notice extends Memcached_DataObject
                            'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
                            'xmlns:media' => 'http://purl.org/syndication/atommedia',
                            'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
-                           'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
+                           'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
+                           'xmlns:statusnet' => 'http://status.net/ont/');
         } else {
             $attrs = array();
         }
@@ -1211,6 +1212,18 @@ class Notice extends Memcached_DataObject
 
             $xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
             $xs->element('updated', null, common_date_w3dtf($this->created));
+
+            $noticeInfoAttr = array(
+                'local_id'   => $this->id,    // local notice ID (useful to clients for ordering)
+                'source'     => $this->source // the client name (source attribution)
+                // @todo source source_link
+                );
+
+            if (!empty($cur)) {
+                $noticeInfoAttr['favorited'] = ($cur->hasFave($this)) ? 'true' : 'false';
+            }
+
+            $xs->element('statusnet:notice_info', $noticeInfoAttr, null);
         }
 
         if ($source) {
index e4df731fe02a5c3bdb7657f6d504177395345ae1..35a45118ce6525ed2f6ce52ba846e307e9d2a9af 100644 (file)
@@ -79,6 +79,11 @@ class AtomNoticeFeed extends Atom10Feed
             'ostatus',
             'http://ostatus.org/schema/1.0'
         );
+
+        $this->addNamespace(
+            'statusnet',
+            'http://status.net/ont/'
+        );
     }
 
     /**
@@ -110,7 +115,9 @@ class AtomNoticeFeed extends Atom10Feed
         $source = $this->showSource();
         $author = $this->showAuthor();
 
-        $this->addEntryRaw($notice->asAtomEntry(false, $source, $author));
+        $cur = common_current_user();
+
+        $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur));
     }
 
     function showSource()