summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-08 21:55:32 -0800
committerZach Copley <zach@status.net>2010-02-08 21:55:32 -0800
commit602b01a7554a2ba50ed169db45d57c54823642a0 (patch)
treec1ad0dc29faec3149610e6885e67e91671c5c98e
parentb56b154b51ede363ee8e49ec5b9b9332b8df923c (diff)
parent4e6f587f868d71f08c618d0dedf6ddf0331619c2 (diff)
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
* 'testing' of gitorious.org:statusnet/mainline: Pull GeoRSS locations over OStatus feeds Allow scripts/decache.php to blow out cache for objects that don't exist (anymore). OStatus cleanup... readme and version for beta5 Delete old Twitter user record when user changes screen name instead of updating. Simpler. Store Twitter screen_name, not name, for foreign_user.nickname when saving Twitter user. Actually store the timestamp on each nonce OAuth app name should not be null Fix issue with OAuth request parameters being parsed/stored twice when - Fix cache handling in TwitterStatusFetcher Added right margin for notice text. Helps Conversation notices look Confirm dialog for reset OAuth consumer key and secret button Always check for an OAuth request. This allows OAuth clients to set an Linkify notice source when posting from registered OAuth apps Suppress notice input box on OAuth authorization page Better token revocation Allow developers to delete OAuth applications OAuth app names should be unique. Prevents app statistic text from wrapping around avatar Sentence case for app statistics
-rw-r--r--actions/showstream.php4
-rw-r--r--classes/Notice.php4
-rw-r--r--lib/util.php3
-rw-r--r--plugins/OStatus/OStatusPlugin.php8
-rw-r--r--plugins/OStatus/actions/pushcallback.php (renamed from plugins/OStatus/actions/feedsubcallback.php)2
-rw-r--r--plugins/OStatus/actions/pushhub.php (renamed from plugins/OStatus/actions/hub.php)2
-rw-r--r--plugins/OStatus/classes/Feedinfo.php2
-rw-r--r--plugins/OStatus/lib/feeddiscovery.php22
-rw-r--r--plugins/OStatus/lib/feedmunger.php84
-rw-r--r--scripts/decache.php8
10 files changed, 103 insertions, 36 deletions
diff --git a/actions/showstream.php b/actions/showstream.php
index 07cc68b76..f9407e35a 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -131,14 +131,14 @@ class ShowstreamAction extends ProfileAction
new Feed(Feed::RSS2,
common_local_url('ApiTimelineUser',
array(
- 'id' => $this->user->nickname,
+ 'id' => $this->user->id,
'format' => 'rss')),
sprintf(_('Notice feed for %s (RSS 2.0)'),
$this->user->nickname)),
new Feed(Feed::ATOM,
common_local_url('ApiTimelineUser',
array(
- 'id' => $this->user->nickname,
+ 'id' => $this->user->id,
'format' => 'atom')),
sprintf(_('Notice feed for %s (Atom)'),
$this->user->nickname)),
diff --git a/classes/Notice.php b/classes/Notice.php
index f9f386357..fca1c599c 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1176,6 +1176,10 @@ class Notice extends Memcached_DataObject
// Figure out who that is.
$sender = Profile::staticGet('id', $profile_id);
+ if (empty($sender)) {
+ return null;
+ }
+
$recipient = common_relative_profile($sender, $nickname, common_sql_now());
if (empty($recipient)) {
diff --git a/lib/util.php b/lib/util.php
index f0f262dc5..00c21aeb2 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -665,6 +665,9 @@ function common_valid_profile_tag($str)
function common_at_link($sender_id, $nickname)
{
$sender = Profile::staticGet($sender_id);
+ if (!$sender) {
+ return $nickname;
+ }
$recipient = common_relative_profile($sender, common_canonical_nickname($nickname));
if ($recipient) {
$user = User::staticGet('id', $recipient->id);
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 941912112..4e8b892c6 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -53,10 +53,10 @@ class OStatusPlugin extends Plugin
*/
function onRouterInitialized($m)
{
- $m->connect('push/hub', array('action' => 'hub'));
+ $m->connect('main/push/hub', array('action' => 'pushhub'));
- $m->connect('feedsub/callback/:feed',
- array('action' => 'feedsubcallback'),
+ $m->connect('main/push/callback/:feed',
+ array('action' => 'pushcallback'),
array('feed' => '[0-9]+'));
$m->connect('settings/feedsub',
array('action' => 'feedsubsettings'));
@@ -97,7 +97,7 @@ class OStatusPlugin extends Plugin
// Canonical form of id in URL?
// Updates will be handled for our internal PuSH hub.
$action->element('link', array('rel' => 'hub',
- 'href' => common_local_url('hub')));
+ 'href' => common_local_url('pushhub')));
}
}
return true;
diff --git a/plugins/OStatus/actions/feedsubcallback.php b/plugins/OStatus/actions/pushcallback.php
index c57ea5b10..a5e02e08f 100644
--- a/plugins/OStatus/actions/feedsubcallback.php
+++ b/plugins/OStatus/actions/pushcallback.php
@@ -25,7 +25,7 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-class FeedSubCallbackAction extends Action
+class PushCallbackAction extends Action
{
function handle()
{
diff --git a/plugins/OStatus/actions/hub.php b/plugins/OStatus/actions/pushhub.php
index 5caf4b48e..901c18f70 100644
--- a/plugins/OStatus/actions/hub.php
+++ b/plugins/OStatus/actions/pushhub.php
@@ -37,7 +37,7 @@ Things to consider...
*/
-class HubAction extends Action
+class PushHubAction extends Action
{
function arg($arg, $def=null)
{
diff --git a/plugins/OStatus/classes/Feedinfo.php b/plugins/OStatus/classes/Feedinfo.php
index f29d08cb0..107faf012 100644
--- a/plugins/OStatus/classes/Feedinfo.php
+++ b/plugins/OStatus/classes/Feedinfo.php
@@ -248,7 +248,7 @@ class Feedinfo extends Memcached_DataObject
#$this->verify_token = $token;
#$this->update(); // @fixme
try {
- $callback = common_local_url('feedsubcallback', array('feed' => $this->id));
+ $callback = common_local_url('pushcallback', array('feed' => $this->id));
$headers = array('Content-Type: application/x-www-form-urlencoded');
$post = array('hub.mode' => 'subscribe',
'hub.callback' => $callback,
diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php
index 9bc7892fb..39985fc90 100644
--- a/plugins/OStatus/lib/feeddiscovery.php
+++ b/plugins/OStatus/lib/feeddiscovery.php
@@ -168,7 +168,13 @@ class FeedDiscovery
}
// Ok... now on to the links!
+ // Types listed in order of priority -- we'll prefer Atom if available.
// @fixme merge with the munger link checks
+ $feeds = array(
+ 'application/atom+xml' => false,
+ 'application/rss+xml' => false,
+ );
+
$nodes = $dom->getElementsByTagName('link');
for ($i = 0; $i < $nodes->length; $i++) {
$node = $nodes->item($i);
@@ -181,17 +187,21 @@ class FeedDiscovery
$type = trim($type->value);
$href = trim($href->value);
- $feedTypes = array(
- 'application/rss+xml',
- 'application/atom+xml',
- );
- if (trim($rel) == 'alternate' && in_array($type, $feedTypes)) {
- return $this->resolveURI($href, $base);
+ if (trim($rel) == 'alternate' && array_key_exists($type, $feeds) && empty($feeds[$type])) {
+ // Save the first feed found of each type...
+ $feeds[$type] = $this->resolveURI($href, $base);
}
}
}
}
+ // Return the highest-priority feed found
+ foreach ($feeds as $type => $url) {
+ if ($url) {
+ return $url;
+ }
+ }
+
return false;
}
diff --git a/plugins/OStatus/lib/feedmunger.php b/plugins/OStatus/lib/feedmunger.php
index eeb8d2df3..cbaec6775 100644
--- a/plugins/OStatus/lib/feedmunger.php
+++ b/plugins/OStatus/lib/feedmunger.php
@@ -225,44 +225,90 @@ class FeedMunger
$notice->created = common_sql_date($entry->updated); // @fixme
$notice->is_local = Notice::GATEWAY;
$notice->source = 'feed';
-
+
+ $location = $this->getLocation($entry);
+ if ($location) {
+ if ($location->location_id) {
+ $notice->location_ns = $location->location_ns;
+ $notice->location_id = $location->location_id;
+ }
+ $notice->lat = $location->lat;
+ $notice->lon = $location->lon;
+ }
+
return $notice;
}
/**
+ * @param feed item $entry
+ * @return mixed Location or false
+ */
+ function getLocation($entry)
+ {
+ $dom = $entry->model;
+ $points = $dom->getElementsByTagNameNS('http://www.georss.org/georss', 'point');
+
+ for ($i = 0; $i < $points->length; $i++) {
+ $point = trim($points->item(0)->textContent);
+ $coords = explode(' ', $point);
+ if (count($coords) == 2) {
+ list($lat, $lon) = $coords;
+ if (is_numeric($lat) && is_numeric($lon)) {
+ common_log(LOG_INFO, "Looking up location for $lat $lon from georss");
+ return Location::fromLatLon($lat, $lon);
+ }
+ }
+ common_log(LOG_ERR, "Ignoring bogus georss:point value $point");
+ }
+
+ return false;
+ }
+
+ /**
* @param XML_Feed_Type $entry
* @return string notice text, within post size limit
*/
function noticeFromEntry($entry)
{
+ $max = Notice::maxContent();
+ $ellipsis = "\xe2\x80\xa6"; // U+2026 HORIZONTAL ELLIPSIS
$title = $entry->title;
$link = $entry->link;
-
+
// @todo We can get <category> entries like this:
// $cats = $entry->getCategory('category', array(0, true));
// but it feels like an awful hack. If it's accessible cleanly,
// try adding #hashtags from the categories/tags on a post.
-
- // @todo Should we force a language here?
- $format = _m('New post: "%1$s" %2$s');
+
$title = $entry->title;
$link = $this->getAltLink($entry);
- $out = sprintf($format, $title, $link);
-
- // Trim link if needed...
- $max = Notice::maxContent();
- if (mb_strlen($out) > $max) {
- $link = common_shorten_url($link);
+ if ($link) {
+ // Blog post or such...
+ // @todo Should we force a language here?
+ $format = _m('New post: "%1$s" %2$s');
$out = sprintf($format, $title, $link);
- }
- // Trim title if needed...
- if (mb_strlen($out) > $max) {
- $ellipsis = "\xe2\x80\xa6"; // U+2026 HORIZONTAL ELLIPSIS
- $used = mb_strlen($out) - mb_strlen($title);
- $available = $max - $used - mb_strlen($ellipsis);
- $title = mb_substr($title, 0, $available) . $ellipsis;
- $out = sprintf($format, $title, $link);
+ // Trim link if needed...
+ if (mb_strlen($out) > $max) {
+ $link = common_shorten_url($link);
+ $out = sprintf($format, $title, $link);
+ }
+
+ // Trim title if needed...
+ if (mb_strlen($out) > $max) {
+ $used = mb_strlen($out) - mb_strlen($title);
+ $available = $max - $used - mb_strlen($ellipsis);
+ $title = mb_substr($title, 0, $available) . $ellipsis;
+ $out = sprintf($format, $title, $link);
+ }
+ } else {
+ // No link? Consider a bare status update.
+ if (mb_strlen($title) > $max) {
+ $available = $max - mb_strlen($ellipsis);
+ $out = mb_substr($title, 0, $available) . $ellipsis;
+ } else {
+ $out = $title;
+ }
}
return $out;
diff --git a/scripts/decache.php b/scripts/decache.php
index 7cabd78ad..094bdb5aa 100644
--- a/scripts/decache.php
+++ b/scripts/decache.php
@@ -24,6 +24,8 @@ $helptext = <<<ENDOFHELP
USAGE: decache.php <table> <id> [<column>]
Clears the cache for the object in table <table> with id <id>
If <column> is specified, use that instead of 'id'
+
+
ENDOFHELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
@@ -43,8 +45,10 @@ if (count($args) > 2) {
$object = Memcached_DataObject::staticGet($table, $column, $id);
if (!$object) {
- print "No such '$table' with $column = '$id'.\n";
- exit(1);
+ print "No such '$table' with $column = '$id'; it's possible some cache keys won't be cleared properly.\n";
+ $class = ucfirst($table);
+ $object = new $class();
+ $object->column = $id;
}
$result = $object->decache();