summaryrefslogtreecommitdiff
path: root/controllers/controllers.php
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/controllers.php')
-rw-r--r--controllers/controllers.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index f9fad25..0917315 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -86,9 +86,17 @@ $app->get('/new/last-photo.json', function() use($app) {
if($user->micropub_media_endpoint) {
// Request the last file uploaded from the media endpoint
- $response = micropub_get($user->micropub_media_endpoint, ['q'=>'last'], $user->micropub_access_token);
- if(isset($response['data']['url'])) {
- $url = $response['data']['url'];
+ $response = micropub_get($user->micropub_media_endpoint, ['q'=>'source', 'limit'=>1], $user->micropub_access_token);
+ if(isset($response['data']['items'])) {
+ $items = $response['data']['items'];
+ if(isset($items[0])) {
+ $item = $items[0];
+ // Only show the file if it was uploaded in the last 5 minutes or if no published date available
+ $show = !isset($item['published']) || (strtotime($item['published']) >= (time()-300));
+ if($show && isset($item['url'])) {
+ $url = $item['url'];
+ }
+ }
}
}