mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add ability to accept and reject remote follows if account is locked
This commit is contained in:
parent
f72671fb07
commit
cf295a596a
5 changed files with 92 additions and 419 deletions
|
|
@ -131,6 +131,44 @@ export const followRequestUser = async (
|
|||
return relationship;
|
||||
};
|
||||
|
||||
export const sendFollowAccept = async (follower: User, followee: User) => {
|
||||
// TODO: Make database job
|
||||
const request = await objectToInboxRequest(
|
||||
followAcceptToLysand(follower, followee),
|
||||
followee,
|
||||
follower,
|
||||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
throw new Error(
|
||||
`Failed to federate follow accept from ${followee.id} to ${follower.uri}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const sendFollowReject = async (follower: User, followee: User) => {
|
||||
// TODO: Make database job
|
||||
const request = await objectToInboxRequest(
|
||||
followRejectToLysand(follower, followee),
|
||||
followee,
|
||||
follower,
|
||||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
throw new Error(
|
||||
`Failed to federate follow reject from ${followee.id} to ${follower.uri}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const resolveUser = async (uri: string) => {
|
||||
// Check if user not already in database
|
||||
const foundUser = await client.user.findUnique({
|
||||
|
|
@ -659,3 +697,13 @@ export const followAcceptToLysand = (
|
|||
uri: new URL(`/follows/${id}`, config.http.base_url).toString(),
|
||||
};
|
||||
};
|
||||
|
||||
export const followRejectToLysand = (
|
||||
follower: User,
|
||||
followee: User,
|
||||
): Lysand.FollowReject => {
|
||||
return {
|
||||
...followAcceptToLysand(follower, followee),
|
||||
type: "FollowReject",
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue