forked from 00dani/lemoncurry
Add a function to convert form-encoded micropub requests into JSON micropub requests - I'll be changing the actual endpoint to accept JSON and use this to keep accepting form-encoded as well
This commit is contained in:
parent
14723b03ff
commit
29a3f740a9
1 changed files with 16 additions and 0 deletions
|
@ -12,6 +12,22 @@ from lemoncurry import utils
|
||||||
from lemonauth import tokens
|
from lemonauth import tokens
|
||||||
|
|
||||||
|
|
||||||
|
def form_to_mf2(post):
|
||||||
|
properties = {}
|
||||||
|
for key in post.keys():
|
||||||
|
if key.endswith('[]'):
|
||||||
|
key = key[:-2]
|
||||||
|
if key == 'access_token':
|
||||||
|
continue
|
||||||
|
properties[key] = post.getlist(key) + post.getlist(key + '[]')
|
||||||
|
|
||||||
|
type = []
|
||||||
|
if 'h' in properties:
|
||||||
|
type = ['h-' + p for p in properties['h']]
|
||||||
|
del properties['h']
|
||||||
|
return {'type': type, 'properties': properties}
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(csrf_exempt, name='dispatch')
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
class MicropubView(View):
|
class MicropubView(View):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
|
Loading…
Reference in a new issue