Add more contribution help

This commit is contained in:
Jesse Wierzbinski 2023-10-22 14:23:15 -10:00
parent 460b68c381
commit 35f54d108f
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
9 changed files with 331 additions and 6 deletions

View file

@ -0,0 +1,49 @@
import { applyConfig } from "@api";
import { errorResponse, jsonResponse } from "@response";
import { MatchedRoute } from "bun";
import { RawObject } from "~database/entities/RawObject";
import { Status } from "~database/entities/Status";
import { User } from "~database/entities/User";
import { APIRouteMeta } from "~types/api";
export const meta: APIRouteMeta = applyConfig({
allowedMethods: ["GET"],
ratelimits: {
max: 100,
duration: 60,
},
route: "/api/v1/statuses/:id/context",
auth: {
required: false,
},
});
/**
* Fetch a user
*/
export default async (
req: Request,
matchedRoute: MatchedRoute
): Promise<Response> => {
// Public for public statuses limited to 40 ancestors and 60 descendants with a maximum depth of 20.
// User token + read:statuses for up to 4,096 ancestors, 4,096 descendants, unlimited depth, and private statuses.
const id = matchedRoute.params.id;
const { user } = await User.getFromRequest(req);
let foundStatus: RawObject | null;
try {
foundStatus = await RawObject.findOneBy({
id,
});
} catch (e) {
return errorResponse("Invalid ID", 404);
}
if (!foundStatus) return errorResponse("Record not found", 404);
// Get all ancestors
const ancestors = await foundStatus.getAncestors();
return jsonResponse({});
};

View file

@ -71,7 +71,16 @@ export default async (
// Delete status and all associated objects
await status.object.remove();
return jsonResponse({}, 200);
return jsonResponse(
{
...(await status.toAPI()),
// TODO: Add
// text: Add source text
// poll: Add source poll
// media_attachments
},
200
);
}
return jsonResponse({});