aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-12-15 18:04:50 +0000
committerJessica Tallon <jessica@megworld.co.uk>2014-12-15 18:04:50 +0000
commit9a51bf1ebcee16169c7dc8ab950b23f7b4a06a22 (patch)
treebf45e821c70104bb590abac2d87cef82d476e740
parent4dec1cd695468ac434bd71eeb329578438054301 (diff)
downloadmediagoblin-9a51bf1ebcee16169c7dc8ab950b23f7b4a06a22.tar.lz
mediagoblin-9a51bf1ebcee16169c7dc8ab950b23f7b4a06a22.tar.xz
mediagoblin-9a51bf1ebcee16169c7dc8ab950b23f7b4a06a22.zip
Fix #1064 - Add major and minor feed for outbox/feed
-rw-r--r--mediagoblin/federation/routing.py18
-rw-r--r--mediagoblin/federation/views.py29
2 files changed, 43 insertions, 4 deletions
diff --git a/mediagoblin/federation/routing.py b/mediagoblin/federation/routing.py
index b585750b..6d86c10e 100644
--- a/mediagoblin/federation/routing.py
+++ b/mediagoblin/federation/routing.py
@@ -40,6 +40,20 @@ add_route(
)
add_route(
+ "mediagoblin.federation.feed_major",
+ "/api/user/<string:username>/feed/major/",
+ "mediagoblin.federation.views:feed_major_endpoint",
+ match_slash=False
+)
+
+add_route(
+ "mediagoblin.federation.feed_minor",
+ "/api/user/<string:username>/feed/minor/",
+ "mediagoblin.federation.views:feed_minor_endpoint",
+ match_slash=False
+)
+
+add_route(
"mediagoblin.federation.user.uploads",
"/api/user/<string:username>/uploads/",
"mediagoblin.federation.views:uploads_endpoint",
@@ -76,14 +90,14 @@ add_route(
add_route(
"mediagoblin.federation.inbox_direct_minor",
- "/api/user/<string:username>/inbox/direct/minor",
+ "/api/user/<string:username>/inbox/direct/minor/",
"mediagoblin.federation.views:inbox_minor_endpoint",
match_slash=False
)
add_route(
"mediagoblin.federation.inbox_direct_major",
- "/api/user/<string:username>/inbox/direct/major",
+ "/api/user/<string:username>/inbox/direct/major/",
"mediagoblin.federation.views:inbox_major_endpoint",
match_slash=False
)
diff --git a/mediagoblin/federation/views.py b/mediagoblin/federation/views.py
index 40873cea..69dee7fb 100644
--- a/mediagoblin/federation/views.py
+++ b/mediagoblin/federation/views.py
@@ -210,7 +210,7 @@ def inbox_major_endpoint(request):
@oauth_required
@csrf_exempt
-def feed_endpoint(request):
+def feed_endpoint(request, outbox=None):
""" Handles the user's outbox - /api/user/<username>/feed """
username = request.matchdict["username"]
requested_user = User.query.filter_by(username=username).first()
@@ -524,7 +524,10 @@ def feed_endpoint(request):
}
# Create outbox
- outbox = Activity.query.filter_by(actor=request.user.id)
+ if outbox is None:
+ outbox = Activity.query.filter_by(actor=request.user.id)
+ else:
+ outbox = outbox.filter_by(actor=request.user.id)
# We want the newest things at the top (issue: #1055)
outbox = outbox.order_by(Activity.published.desc())
@@ -550,6 +553,28 @@ def feed_endpoint(request):
return json_response(feed)
@oauth_required
+def feed_minor_endpoint(request):
+ """ Outbox for minor activities such as updates """
+ # If it's anything but GET pass it along
+ if request.method != "GET":
+ return feed_endpoint(request)
+
+ outbox = Activity.query.filter(
+ (Activity.verb == "update") | (Activity.verb == "delete")
+ )
+ return feed_endpoint(request, outbox=outbox)
+
+@oauth_required
+def feed_major_endpoint(request):
+ """ Outbox for all major activities """
+ # If it's anything but a GET pass it along
+ if request.method != "GET":
+ return feed_endpoint(request)
+
+ outbox = Activity.query.filter_by(verb="post")
+ return feed_endpoint(request, outbox=outbox)
+
+@oauth_required
def object_endpoint(request):
""" Lookup for a object type """
object_type = request.matchdict["object_type"]