mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
Add FollowAccept handling
This commit is contained in:
parent
27a287ab4d
commit
820d05c997
|
|
@ -212,6 +212,34 @@ export default apiRoute(async (req, matchedRoute, extraData) => {
|
||||||
|
|
||||||
return response("Follow request sent", 200);
|
return response("Follow request sent", 200);
|
||||||
}
|
}
|
||||||
|
case "FollowAccept": {
|
||||||
|
const followAccept = body as Lysand.FollowAccept;
|
||||||
|
|
||||||
|
const account = await resolveUser(followAccept.author);
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
|
return errorResponse("Author not found", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relationship = await getRelationshipToOtherUser(
|
||||||
|
user,
|
||||||
|
account,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!relationship.requested) {
|
||||||
|
return response("There is no follow request to accept", 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
await client.relationship.update({
|
||||||
|
where: { id: relationship.id },
|
||||||
|
data: {
|
||||||
|
following: true,
|
||||||
|
requested: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return response("Follow request accepted", 200);
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return errorResponse("Unknown object type", 400);
|
return errorResponse("Unknown object type", 400);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue