mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
Test for Update support
This commit is contained in:
parent
d92764d81a
commit
aad3ee78d1
2 changed files with 79 additions and 5 deletions
|
|
@ -78,17 +78,26 @@ export default async (
|
|||
// Replace the object in database with the new provided object
|
||||
// TODO: Add authentication
|
||||
|
||||
const object = await RawObject.findOneBy({
|
||||
data: {
|
||||
id: (body.object as RawObject).id,
|
||||
},
|
||||
});
|
||||
const object = await RawObject.createQueryBuilder("object")
|
||||
.where("object.data->>'id' = :id", {
|
||||
id: (body.object as APObject).id,
|
||||
})
|
||||
.getOne();
|
||||
|
||||
if (!object) return errorResponse("Object not found", 404);
|
||||
|
||||
object.data = body.object as APObject;
|
||||
|
||||
// Store the Update event in database
|
||||
const activity = new RawActivity();
|
||||
activity.data = {
|
||||
...body,
|
||||
object: undefined,
|
||||
};
|
||||
activity.objects = [object];
|
||||
|
||||
await object.save();
|
||||
await activity.save();
|
||||
break;
|
||||
}
|
||||
case "Delete" as APDelete: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue