aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/federation
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-07-11 15:23:55 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-07-22 23:13:16 +0100
commit51ab51921e5104f1b71402d38928651562c7134a (patch)
treec83072931ed60b597ff48f036c394f97bb739557 /mediagoblin/federation
parent967df5eff0c00fe7cd860ebfb297ee1f2e0bcdaf (diff)
downloadmediagoblin-51ab51921e5104f1b71402d38928651562c7134a.tar.lz
mediagoblin-51ab51921e5104f1b71402d38928651562c7134a.tar.xz
mediagoblin-51ab51921e5104f1b71402d38928651562c7134a.zip
Add more tests for federation APIs
Diffstat (limited to 'mediagoblin/federation')
-rw-r--r--mediagoblin/federation/views.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/mediagoblin/federation/views.py b/mediagoblin/federation/views.py
index 6e4d81d4..c2b02ec0 100644
--- a/mediagoblin/federation/views.py
+++ b/mediagoblin/federation/views.py
@@ -116,15 +116,27 @@ def feed(request):
elif obj.get("objectType", None) == "image":
# Posting an image to the feed
- # NB: This is currently just handing the image back until we have an
- # to send the image to the actual feed
-
media_id = int(data["object"]["id"])
media = MediaEntry.query.filter_by(id=media_id)
if media is None:
error = "No such 'image' with id '{0}'".format(id=media_id)
return json_response(error, status=404)
- media = media[0]
+
+ media = media.first()
+ obj = data["object"]
+
+ if "displayName" in obj:
+ media.title = obj["displayName"]
+
+ if "content" in obj:
+ media.description = obj["content"]
+
+ if "license" in obj:
+ media.license = obj["license"]
+
+ media.save()
+ manager = media.media_manager.api_add_to_feed(request, media)
+
return json_response({
"verb": "post",
"object": media.serialize(request)
@@ -206,6 +218,11 @@ def feed(request):
}
return json_response(activity)
+ elif request.method != "GET":
+ # Currently unsupported
+ error = "Unsupported HTTP method {0}".format(request.method)
+ return json_response({"error": error}, status=501)
+
feed_url = request.urlgen(
"mediagoblin.federation.feed",
username=request.user.username,