summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/oauthstore.php2
-rw-r--r--lib/popularnoticesection.php6
-rw-r--r--lib/router.php21
-rw-r--r--lib/twitterapi.php41
4 files changed, 40 insertions, 30 deletions
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index 7ad3be20e..9af05ea2d 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -63,7 +63,7 @@ class LaconicaOAuthDataStore extends OAuthDataStore
if ($n->find(true)) {
return true;
} else {
- $n->timestamp = $timestamp;
+ $n->ts = $timestamp;
$n->created = DB_DataObject_Cast::dateTime();
$n->insert();
return false;
diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php
index f7fb93554..0505f0fa9 100644
--- a/lib/popularnoticesection.php
+++ b/lib/popularnoticesection.php
@@ -54,10 +54,12 @@ class PopularNoticeSection extends NoticeSection
$weightexpr='sum(exp(-(now() - fave.modified) / %s))';
}
- $qry = 'SELECT notice.id, '.
+ $qry = 'SELECT notice.*, '.
$weightexpr . ' as weight ' .
'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
- 'GROUP BY notice.id ' .
+ 'GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' .
+ 'notice.rendered,notice.url,notice.created,notice.modified,' .
+ 'notice.reply_to,notice.is_local,notice.source ' .
'ORDER BY weight DESC';
$offset = 0;
diff --git a/lib/router.php b/lib/router.php
index d4a4d2ca9..41c376a72 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -228,14 +228,15 @@ class Router
// users
- $m->connect('api/users/show/:argument',
+ $m->connect('api/users/:method/:argument',
array('action' => 'api',
- 'apiaction' => 'users'));
+ 'apiaction' => 'users'),
+ array('method' => 'show(\.(xml|json))?'));
$m->connect('api/users/:method',
array('action' => 'api',
'apiaction' => 'users'),
- array('method' => 'show(\.(xml|json|atom|rss))?'));
+ array('method' => 'show(\.(xml|json))?'));
// direct messages
@@ -283,14 +284,14 @@ class Router
array('action' => 'api',
'apiaction' => 'statuses',
'method' => 'friendsIDs'));
-
+
foreach (array('xml', 'json') as $e) {
$m->connect('api/friends/ids.'.$e,
array('action' => 'api',
'apiaction' => 'statuses',
'method' => 'friendsIDs.'.$e));
}
-
+
$m->connect('api/followers/ids/:argument',
array('action' => 'api',
'apiaction' => 'statuses',
@@ -351,6 +352,16 @@ class Router
array('action' => 'api',
'apiaction' => 'laconica'));
+
+ // search
+
+ foreach (array('json', 'atom') as $e) {
+ $m->connect('api/search.'.$e,
+ array('action' => 'twitapisearch'));
+ }
+
+ $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+
// user stuff
foreach (array('subscriptions', 'subscribers',
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index a4d183fcd..74f265cbb 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -60,20 +60,34 @@ class TwitterapiAction extends Action
function twitter_status_array($notice, $include_user=true)
{
-
$profile = $notice->getProfile();
$twitter_status = array();
$twitter_status['text'] = $notice->content;
$twitter_status['truncated'] = 'false'; # Not possible on Laconica
$twitter_status['created_at'] = $this->date_twitter($notice->created);
- $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : null;
+ $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
+ intval($notice->reply_to) : null;
$twitter_status['source'] = $this->source_link($notice->source);
$twitter_status['id'] = intval($notice->id);
- $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply(intval($notice->reply_to)) : null;
+
+ $replier_profile = null;
+
+ if ($notice->reply_to) {
+ $reply = Notice::staticGet(intval($notice->reply_to));
+ if ($reply) {
+ $replier_profile = $reply->getProfile();
+ }
+ }
+
+ $twitter_status['in_reply_to_user_id'] =
+ ($replier_profile) ? intval($replier_profile->id) : null;
+ $twitter_status['in_reply_to_screen_name'] =
+ ($replier_profile) ? $replier_profile->nickname : null;
if (isset($this->auth_user)) {
- $twitter_status['favorited'] = ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
+ $twitter_status['favorited'] =
+ ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
} else {
$twitter_status['favorited'] = 'false';
}
@@ -137,7 +151,6 @@ class TwitterapiAction extends Action
function twitter_dmsg_array($message)
{
-
$twitter_dm = array();
$from_profile = $message->getFrom();
@@ -386,23 +399,7 @@ class TwitterapiAction extends Action
$t = strtotime($dt);
return date("D M d G:i:s O Y", $t);
}
-
- function replier_by_reply($reply_id)
- {
- $notice = Notice::staticGet($reply_id);
- if ($notice) {
- $profile = $notice->getProfile();
- if ($profile) {
- return intval($profile->id);
- } else {
- common_debug('Can\'t find a profile for notice: ' . $notice->id, __FILE__);
- }
- } else {
- common_debug("Can't get notice: $reply_id", __FILE__);
- }
- return null;
- }
-
+
// XXX: Candidate for a general utility method somewhere?
function count_subscriptions($profile)
{