mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
Add more contribution help
This commit is contained in:
parent
460b68c381
commit
35f54d108f
9 changed files with 331 additions and 6 deletions
49
server/api/api/v1/statuses/[id]/context.ts
Normal file
49
server/api/api/v1/statuses/[id]/context.ts
Normal 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({});
|
||||
};
|
||||
|
|
@ -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({});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue