summaryrefslogtreecommitdiff
path: root/lib/helpers.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helpers.php')
-rw-r--r--lib/helpers.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index bfcdf63..d714c23 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -288,12 +288,19 @@ function get_micropub_config(&$user, $query=[]) {
$user->syndication_targets = json_encode($targets);
$media_endpoint = false;
- if($r['data'] && is_array($r['data']) && array_key_exists('media-endpoint', $r['data'])) {
- $media_endpoint = $r['data']['media-endpoint'];
- $user->micropub_media_endpoint = $media_endpoint;
+ $supported_post_types = false;
+ if($r['data'] && is_array($r['data'])) {
+ if(isset($r['data']['media-endpoint'])) {
+ $media_endpoint = $r['data']['media-endpoint'];
+ $user->micropub_media_endpoint = $media_endpoint;
+ }
+ if(isset($r['data']['post-types'])) {
+ $supported_post_types = json_encode($r['data']['post-types']);
+ $user->supported_post_types = $supported_post_types;
+ }
}
- if(count($targets) || $media_endpoint) {
+ if(count($targets) || $media_endpoint || $supported_post_types) {
$user->save();
}
@@ -303,6 +310,23 @@ function get_micropub_config(&$user, $query=[]) {
];
}
+function supports_post_type(&$user, $type) {
+ if(!$user->supported_post_types)
+ return true;
+
+ $types = json_decode($user->supported_post_types, true);
+ if(!is_array($types))
+ return true; // syntax error in response, fail safely
+
+ foreach($types as $t) {
+ if(is_array($t) && isset($t['type']) && $t['type'] == $type) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
function get_micropub_source(&$user, $url, $properties) {
$r = micropub_get($user->micropub_endpoint, [
'q' => 'source',