]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
UserRSS Didn't Use the Tag Propery.
[quix0rs-gnu-social.git] / classes / Notice.php
index 63dc9689727cdc41920c3f45fae26434d90884e0..4c7e6ab4b708e7452e34dbc338fa0161cd919a83 100644 (file)
@@ -211,6 +211,8 @@ class Notice extends Memcached_DataObject
      *                              extracting ! tags from content
      *              array 'tags' list of hashtag strings to save with the notice
      *                           in place of extracting # tags from content
+     *              array 'urls' list of attached/referred URLs to save with the
+     *                           notice in place of extracting links from content
      * @fixme tag override
      *
      * @return Notice
@@ -380,8 +382,11 @@ class Notice extends Memcached_DataObject
             $notice->saveTags();
         }
 
-        // @fixme pass in data for URLs too?
-        $notice->saveUrls();
+        if (isset($urls)) {
+            $notice->saveKnownUrls($urls);
+        } else {
+            $notice->saveUrls();
+        }
 
         // Prepare inbox delivery, may be queued to background.
         $notice->distribute();
@@ -427,6 +432,25 @@ class Notice extends Memcached_DataObject
         common_replace_urls_callback($this->content, array($this, 'saveUrl'), $this->id);
     }
 
+    /**
+     * Save the given URLs as related links/attachments to the db
+     *
+     * follow redirects and save all available file information
+     * (mimetype, date, size, oembed, etc.)
+     *
+     * @return void
+     */
+    function saveKnownUrls($urls)
+    {
+        // @fixme validation?
+        foreach ($urls as $url) {
+            File::processNew($url, $this->id);
+        }
+    }
+
+    /**
+     * @private callback
+     */
     function saveUrl($data) {
         list($url, $notice_id) = $data;
         File::processNew($url, $notice_id);
@@ -853,7 +877,7 @@ class Notice extends Memcached_DataObject
 
         foreach (array_unique($match[1]) as $nickname) {
             /* XXX: remote groups. */
-            $group = User_group::getForNickname($nickname);
+            $group = User_group::getForNickname($nickname, $profile);
 
             if (empty($group)) {
                 continue;
@@ -1082,7 +1106,7 @@ class Notice extends Memcached_DataObject
         return $groups;
     }
 
-    function asAtomEntry($namespace=false, $source=false)
+    function asAtomEntry($namespace=false, $source=false, $author=true)
     {
         $profile = $this->getProfile();
 
@@ -1127,8 +1151,10 @@ class Notice extends Memcached_DataObject
 
         $xs->element('title', null, $this->content);
 
-        $xs->raw($profile->asAtomAuthor());
-        $xs->raw($profile->asActivityActor());
+        if ($author) {
+            $xs->raw($profile->asAtomAuthor());
+            $xs->raw($profile->asActivityActor());
+        }
 
         $xs->element('link', array('rel' => 'alternate',
                                    'type' => 'text/html',