refactor(federation): ♻️ Replace WebFinger code with @lysand-org/federation logic, add new debug command

This commit is contained in:
Jesse Wierzbinski 2024-06-29 22:24:10 -10:00
parent 38c8ea24a9
commit cea9452127
No known key found for this signature in database
15 changed files with 256 additions and 99 deletions

View file

@ -509,6 +509,15 @@ export const configValidator = z.object({
privacy_policy_path: z.string().optional(),
logo: zUrl.optional(),
banner: zUrl.optional(),
keys: z
.object({
public: z.string().min(3).default("").or(z.literal("")),
private: z.string().min(3).default("").or(z.literal("")),
})
.default({
public: "",
private: "",
}),
})
.default({
name: "Lysand",
@ -518,6 +527,10 @@ export const configValidator = z.object({
privacy_policy_path: undefined,
logo: undefined,
banner: undefined,
keys: {
public: "",
private: "",
},
}),
permissions: z
.object({

View file

@ -326,7 +326,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
const parsedMentions = [
...(data.mentions ?? []),
...(await parseTextMentions(plaintextContent)),
...(await parseTextMentions(plaintextContent, data.author)),
// Deduplicate by .id
].filter(
(mention, index, self) =>
@ -396,7 +396,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
* @returns The updated note
*/
async updateFromData(data: {
author?: User;
author: User;
content?: ContentFormat;
visibility?: ApiStatus["visibility"];
isSensitive?: boolean;
@ -418,7 +418,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
const parsedMentions = [
...(data.mentions ?? []),
...(plaintextContent
? await parseTextMentions(plaintextContent)
? await parseTextMentions(plaintextContent, data.author)
: []),
// Deduplicate by .id
].filter(

View file

@ -123,6 +123,56 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
);
}
static getServerActor(): User {
return new User({
id: "00000000-0000-0000-0000-000000000000",
username: "actor",
avatar: "",
createdAt: "2024-01-01T00:00:00.000Z",
displayName: "Server Actor",
note: "This is a system actor used for server-to-server communication. It is not a real user.",
updatedAt: "2024-01-01T00:00:00.000Z",
instanceId: null,
publicKey: config.instance.keys.public,
source: {
fields: [],
language: null,
note: "",
privacy: "public",
sensitive: false,
},
fields: [],
isAdmin: false,
isBot: false,
isLocked: false,
isDiscoverable: false,
endpoints: {
dislikes: "",
featured: "",
likes: "",
followers: "",
following: "",
inbox: "",
outbox: "",
},
disableAutomoderation: false,
email: "",
emailVerificationToken: "",
emojis: [],
followerCount: 0,
followingCount: 0,
header: "",
instance: null,
password: "",
passwordResetToken: "",
privateKey: config.instance.keys.private,
roles: [],
sanctions: [],
statusCount: 0,
uri: "",
});
}
static getUri(id: string, uri: string | null, baseUrl: string) {
return uri || new URL(`/users/${id}`, baseUrl).toString();
}