diff --git a/QvitterPlugin.php b/QvitterPlugin.php index c370e0d..78dc60a 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -101,17 +101,7 @@ class QvitterPlugin extends Plugin { array('action' => 'apiqvitterallfollowing', 'id' => Nickname::INPUT_FMT)); $m->connect('api/qvitter/update_cover_photo.json', - array('action' => 'ApiUpdateCoverPhoto')); - $m->connect('api/qvitter/statuses/friends_timeline.json', - array('action' => 'apiqvitterfriends')); - $m->connect('api/qvitter/statuses/friends_timeline/:id.json', - array('action' => 'apiqvitterfriends', - 'id' => Nickname::INPUT_FMT)); - $m->connect('api/qvitter/statuses/mentions/:id.json', - array('action' => 'apiqvittermentions', - 'id' => Nickname::INPUT_FMT)); - $m->connect('api/qvitter/statuses/mentions.:format', - array('action' => 'apiqvittermentions')); + array('action' => 'ApiUpdateCoverPhoto')); $m->connect('api/qvitter/statuses/notifications.json', array('action' => 'apiqvitternotifications')); $m->connect(':nickname/notifications', @@ -259,7 +249,7 @@ class QvitterPlugin extends Plugin { /** - * Group addresses in API response + * Add stuff to notices in API responses * * @param Action $action action being executed * @@ -269,6 +259,7 @@ class QvitterPlugin extends Plugin { function onNoticeSimpleStatusArray($notice, &$twitter_status) { + // groups $notice_groups = $notice->getGroups(); $group_addressees = false; foreach($notice_groups as $g) { @@ -278,6 +269,35 @@ class QvitterPlugin extends Plugin { if($group_addressees == '') $group_addressees = false; $twitter_status['statusnet_in_groups'] = $group_addressees; + + // thumb urls + + // find all thumbs + $attachments = $notice->attachments(); + $attachment_url_to_thumb = array(); + if (!empty($attachments)) { + foreach ($attachments as $attachment) { + try { + $enclosure_o = $attachment->getEnclosure(); + $thumb = File_thumbnail::getKV('file_id', $attachment->id); + if(isset($thumb->url)) { + $attachment_url_to_thumb[$enclosure_o->url] = $thumb->url; + } + } catch (ServerException $e) { + // There was not enough metadata available + } + } + } + + // add thumbs to $twitter_status + if (!empty($twitter_status['attachments'])) { + foreach ($twitter_status['attachments'] as &$attachment) { + if (!empty($attachment_url_to_thumb[$attachment['url']])) { + $attachment['thumb_url'] = $attachment_url_to_thumb[$attachment['url']]; + } + } + } + return true; } diff --git a/actions/apiqvitterfriends.php b/actions/apiqvitterfriends.php deleted file mode 100644 index 37ee411..0000000 --- a/actions/apiqvitterfriends.php +++ /dev/null @@ -1,46 +0,0 @@ - \\\\_\ · - · \\) \____) · - · · - · · - · · - · Qvitter is free software: you can redistribute it and / or modify it · - · under the terms of the GNU Affero General Public License as published by · - · the Free Software Foundation, either version three of the License or (at · - · your option) any later version. · - · · - · Qvitter is distributed in hope that it will be useful but WITHOUT ANY · - · WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS · - · FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for · - · more details. · - · · - · You should have received a copy of the GNU Affero General Public License · - · along with Qvitter. If not, see . · - · · - · Contact h@nnesmannerhe.im if you have any questions. · - · · - · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */ - -if (!defined('GNUSOCIAL')) { exit(1); } - -class ApiQvitterFriendsAction extends ApiTimelineFriendsAction -{ - function showTimeline() - { - ApiQvitterAction::showQvitterJsonTimeline($this->notices); - } -} - - diff --git a/actions/apiqvittermentions.php b/actions/apiqvittermentions.php deleted file mode 100644 index e9b4685..0000000 --- a/actions/apiqvittermentions.php +++ /dev/null @@ -1,44 +0,0 @@ - \\\\_\ · - · \\) \____) · - · · - · · - · · - · Qvitter is free software: you can redistribute it and / or modify it · - · under the terms of the GNU Affero General Public License as published by · - · the Free Software Foundation, either version three of the License or (at · - · your option) any later version. · - · · - · Qvitter is distributed in hope that it will be useful but WITHOUT ANY · - · WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS · - · FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for · - · more details. · - · · - · You should have received a copy of the GNU Affero General Public License · - · along with Qvitter. If not, see . · - · · - · Contact h@nnesmannerhe.im if you have any questions. · - · · - · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */ - -if (!defined('GNUSOCIAL')) { exit(1); } - -class ApiQvitterMentionsAction extends ApiTimelineMentionsAction -{ - function showTimeline() - { - ApiQvitterAction::showQvitterJsonTimeline($this->notices); - } -} \ No newline at end of file diff --git a/actions/apitimelinepublicandexternal.php b/actions/apitimelinepublicandexternal.php index c5ba3c5..7b07b32 100644 --- a/actions/apitimelinepublicandexternal.php +++ b/actions/apitimelinepublicandexternal.php @@ -141,7 +141,7 @@ class ApiTimelinePublicAndExternalAction extends ApiPrivateAuthAction break; case 'json': - ApiQvitterAction::showQvitterJsonTimeline($this->notices); + $this->showJsonTimeline($this->notices); break; case 'as': header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); diff --git a/actions/qvitter.php b/actions/qvitter.php index bde34b9..5a58759 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -351,9 +351,9 @@ class QvitterAction extends ApiAction