summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-03 09:53:38 -0800
committerBrion Vibber <brion@pobox.com>2010-03-03 09:53:38 -0800
commit7313cd909479f771e960466d9194783c9a3158bb (patch)
tree318734efe06c9de904364f04cb76e1c54b75e269 /classes
parent49a872b56f82a3f1ba59f0751c11dfe7754393dd (diff)
parentf3cea2430497e751bc7776fe3abf0603e2b55f8b (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline
Conflicts: plugins/OStatus/OStatusPlugin.php
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php9
-rw-r--r--classes/Notice.php29
2 files changed, 35 insertions, 3 deletions
diff --git a/classes/File.php b/classes/File.php
index 91b12d2e2..1b8ef1b3e 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -279,10 +279,19 @@ class File extends Memcached_DataObject
if($oembed->modified) $enclosure->modified=$oembed->modified;
unset($oembed->size);
}
+ } else {
+ return false;
}
}
}
return $enclosure;
}
+
+ // quick back-compat hack, since there's still code using this
+ function isEnclosure()
+ {
+ $enclosure = $this->getEnclosure();
+ return !empty($enclosure);
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 22dcbcd74..c1263c782 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -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);
@@ -1126,7 +1150,6 @@ class Notice extends Memcached_DataObject
}
$xs->element('title', null, $this->content);
- $xs->element('summary', null, $this->content);
$xs->raw($profile->asAtomAuthor());
$xs->raw($profile->asActivityActor());