fix: deletion should come from pds events
This commit is contained in:
40
server.ts
40
server.ts
@@ -24,26 +24,26 @@ router.get("/:did/notes", (ctx) => {
|
||||
ctx.response.body = getNotesByDid(did, cursor, limit);
|
||||
});
|
||||
|
||||
router.delete("/:did/:rkey", async (ctx) => {
|
||||
const { did, rkey } = ctx.params;
|
||||
let verifiedDid: string;
|
||||
try {
|
||||
verifiedDid = await authenticateRequest(
|
||||
ctx.request.headers.get("Authorization"),
|
||||
);
|
||||
} catch {
|
||||
ctx.response.status = 401;
|
||||
ctx.response.body = { error: "Unauthorized" };
|
||||
return;
|
||||
}
|
||||
if (verifiedDid !== did) {
|
||||
ctx.response.status = 403;
|
||||
ctx.response.body = { error: "You can only delete your own notes" };
|
||||
return;
|
||||
}
|
||||
deleteNote({ did, rkey });
|
||||
ctx.response.status = 204;
|
||||
})
|
||||
// router.delete("/:did/:rkey", async (ctx) => {
|
||||
// const { did, rkey } = ctx.params;
|
||||
// let verifiedDid: string;
|
||||
// try {
|
||||
// verifiedDid = await authenticateRequest(
|
||||
// ctx.request.headers.get("Authorization"),
|
||||
// );
|
||||
// } catch {
|
||||
// ctx.response.status = 401;
|
||||
// ctx.response.body = { error: "Unauthorized" };
|
||||
// return;
|
||||
// }
|
||||
// if (verifiedDid !== did) {
|
||||
// ctx.response.status = 403;
|
||||
// ctx.response.body = { error: "You can only delete your own notes" };
|
||||
// return;
|
||||
// }
|
||||
// deleteNote({ did, rkey });
|
||||
// ctx.response.status = 204;
|
||||
// })
|
||||
|
||||
const app = new Application();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user