summaryrefslogtreecommitdiff
path: root/controllers/controllers.php
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/controllers.php')
-rw-r--r--controllers/controllers.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 4373fcf..2a90892 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -76,6 +76,7 @@ $app->get('/new', function() use($app) {
'title' => 'New Post',
'in_reply_to' => $in_reply_to,
'micropub_endpoint' => $user->micropub_endpoint,
+ 'media_endpoint' => $user->micropub_media_endpoint,
'micropub_scope' => $user->micropub_scope,
'micropub_access_token' => $user->micropub_access_token,
'response_date' => $user->last_micropub_response_date,
@@ -452,7 +453,7 @@ $app->post('/repost', function() use($app) {
$app->get('/micropub/syndications', function() use($app) {
if($user=require_login($app)) {
- $data = get_syndication_targets($user);
+ $data = get_micropub_config($user, ['q'=>'syndicate-to']);
$app->response()->body(json_encode(array(
'targets' => $data['targets'],
'response' => $data['response']
@@ -522,6 +523,31 @@ $app->post('/micropub/multipart', function() use($app) {
}
});
+$app->post('/micropub/media', function() use($app) {
+ if($user=require_login($app)) {
+ $file = isset($_FILES['photo']) ? $_FILES['photo'] : null;
+ $error = validate_photo($file);
+ unset($_POST['null']);
+
+ if(!$error) {
+ $file_path = $file['tmp_name'];
+ correct_photo_rotation($file_path);
+ $r = micropub_media_post_for_user($user, $file_path);
+ } else {
+ $r = array('error' => $error);
+ }
+
+ if(empty($r['location']) && empty($r['error'])) {
+ $r['error'] = "No 'Location' header in response.";
+ }
+
+ $app->response()->body(json_encode(array(
+ 'location' => (isset($r['location']) ? $r['location'] : null),
+ 'error' => (isset($r['error']) ? $r['error'] : null),
+ )));
+ }
+});
+
$app->post('/micropub/postjson', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();