diff --git a/activitypub.py b/activitypub.py index ed1a690..ec621e9 100644 --- a/activitypub.py +++ b/activitypub.py @@ -638,6 +638,16 @@ def embed_collection(total_items, first_page_id): } +def simple_build_ordered_collection(col_name, data): + return { + "@context": ap.COLLECTION_CTX, + "id": BASE_URL + "/" + col_name, + "totalItems": len(data), + "type": ap.ActivityType.ORDERED_COLLECTION.value, + "orederedItems": data, + } + + def build_ordered_collection( col, q=None, cursor=None, map_func=None, limit=50, col_name=None, first_page=False ): @@ -652,6 +662,7 @@ def build_ordered_collection( if not data: return { + "@context": ap.COLLECTION_CTX, "id": BASE_URL + "/" + col_name, "totalItems": 0, "type": ap.ActivityType.ORDERED_COLLECTION.value, diff --git a/app.py b/app.py index b2dd57c..07bcdaa 100644 --- a/app.py +++ b/app.py @@ -23,10 +23,10 @@ import timeago from bson.objectid import ObjectId from dateutil import parser from flask import Flask +from flask import make_response from flask import Response from flask import abort from flask import jsonify as flask_jsonify -from flask import make_response from flask import redirect from flask import render_template from flask import request @@ -1779,6 +1779,13 @@ def tags(tag): ) +@app.route("/featured") +def featured(): + if not is_api_request(): + abort(404) + return jsonify(**activitypub.simple_build_ordered_collection("featured", [])) + + @app.route("/liked") def liked(): if not is_api_request(): diff --git a/config.py b/config.py index d824611..db39fb0 100644 --- a/config.py +++ b/config.py @@ -131,6 +131,7 @@ ME = { "id": ID, "following": ID + "/following", "followers": ID + "/followers", + "featured": ID + "/featured", "liked": ID + "/liked", "inbox": ID + "/inbox", "outbox": ID + "/outbox",