diff options
author | xray7224 <jessica@megworld.co.uk> | 2013-09-02 19:25:24 +0100 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2014-07-22 23:13:14 +0100 |
commit | 98596dd072597c5d9c474e882f57407817d049f5 (patch) | |
tree | 27c3e20040d8e76ac6cf41c6a7b1fa17d0a8afc4 /mediagoblin/federation/views.py | |
parent | 37f070b06786c20f320231bc467b35ccab6270dc (diff) | |
download | mediagoblin-98596dd072597c5d9c474e882f57407817d049f5.tar.lz mediagoblin-98596dd072597c5d9c474e882f57407817d049f5.tar.xz mediagoblin-98596dd072597c5d9c474e882f57407817d049f5.zip |
Support for the comments endpoint
Diffstat (limited to 'mediagoblin/federation/views.py')
-rw-r--r-- | mediagoblin/federation/views.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/mediagoblin/federation/views.py b/mediagoblin/federation/views.py index 01082942..ab67e457 100644 --- a/mediagoblin/federation/views.py +++ b/mediagoblin/federation/views.py @@ -39,8 +39,8 @@ def inbox(request): """ Handles the user's inbox - /api/user/<username>/inbox """ raise NotImplemented("Yet to implement looking up user's inbox") -@oauth_required -def object(request): +#@oauth_required +def object(request, raw_obj=False): """ Lookup for a object type """ objectType = request.matchdict["objectType"] uuid = request.matchdict["uuid"] @@ -55,4 +55,26 @@ def object(request): error = "Can't find a {0} with ID = {1}".format(objectType, uuid) return json_response({"error": error}, status=404) + if raw_obj: + return media + return json_response(media.serialize(request)) + +def object_comments(request): + """ Looks up for the comments on a object """ + media = object(request, raw_obj=True) + response = media + if isinstance(response, MediaEntry): + comments = response.serialize(request) + comments = comments.get("replies", { + "totalItems": 0, + "items": [], + "url": request.urlgen( + "mediagoblin.federation.object.comments", + objectType=media.objectType, + uuid=media.slug, + qualified=True) + }) + response = json_response(comments) + + return response |