Fix #1064 - Add major and minor feed for outbox/feed

This commit is contained in:
Jessica Tallon 2014-12-15 18:04:50 +00:00
parent 4dec1cd695
commit 9a51bf1ebc
2 changed files with 43 additions and 4 deletions

View File

@ -39,6 +39,20 @@ add_route(
match_slash=False
)
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/",
@ -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
)

View File

@ -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())
@ -549,6 +552,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 """