mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(federation): ✨ Prioritize delivery to instance inbox, and use delivery queue in more places
This commit is contained in:
parent
7a73a1a24e
commit
c899f12893
2 changed files with 88 additions and 123 deletions
|
|
@ -1,8 +1,3 @@
|
|||
import type {
|
||||
Follow,
|
||||
FollowAccept,
|
||||
FollowReject,
|
||||
} from "@versia/federation/types";
|
||||
import {
|
||||
type Application,
|
||||
type Emoji,
|
||||
|
|
@ -138,67 +133,3 @@ export const findManyUsers = async (
|
|||
|
||||
return output.map((user) => transformOutputToUserWithRelations(user));
|
||||
};
|
||||
|
||||
export const followRequestToVersia = (
|
||||
follower: User,
|
||||
followee: User,
|
||||
): Follow => {
|
||||
if (follower.isRemote()) {
|
||||
throw new Error("Follower must be a local user");
|
||||
}
|
||||
|
||||
if (!followee.isRemote()) {
|
||||
throw new Error("Followee must be a remote user");
|
||||
}
|
||||
|
||||
if (!followee.data.uri) {
|
||||
throw new Error("Followee must have a URI in database");
|
||||
}
|
||||
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
return {
|
||||
type: "Follow",
|
||||
id,
|
||||
author: follower.getUri(),
|
||||
followee: followee.getUri(),
|
||||
created_at: new Date().toISOString(),
|
||||
};
|
||||
};
|
||||
|
||||
export const followAcceptToVersia = (
|
||||
follower: User,
|
||||
followee: User,
|
||||
): FollowAccept => {
|
||||
if (!follower.isRemote()) {
|
||||
throw new Error("Follower must be a remote user");
|
||||
}
|
||||
|
||||
if (followee.isRemote()) {
|
||||
throw new Error("Followee must be a local user");
|
||||
}
|
||||
|
||||
if (!follower.data.uri) {
|
||||
throw new Error("Follower must have a URI in database");
|
||||
}
|
||||
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
return {
|
||||
type: "FollowAccept",
|
||||
id,
|
||||
author: followee.getUri(),
|
||||
created_at: new Date().toISOString(),
|
||||
follower: follower.getUri(),
|
||||
};
|
||||
};
|
||||
|
||||
export const followRejectToVersia = (
|
||||
follower: User,
|
||||
followee: User,
|
||||
): FollowReject => {
|
||||
return {
|
||||
...followAcceptToVersia(follower, followee),
|
||||
type: "FollowReject",
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue