feat(federation): Add ActivityPub bridge support with CLI command

This commit is contained in:
Jesse Wierzbinski 2024-07-16 23:29:20 +02:00
parent 153aa061f0
commit ff315af230
No known key found for this signature in database
13 changed files with 2337 additions and 15 deletions

View file

@ -471,13 +471,19 @@ export const configValidator = z.object({
software: z.enum(["lysand-ap"]).or(z.string()),
allowed_ips: z.array(z.string().trim()).default([]),
token: z.string().default(""),
url: zUrl.optional(),
})
.default({
enabled: false,
software: "lysand-ap",
allowed_ips: [],
token: "",
}),
url: "",
})
.refine(
(arg) => (arg.enabled ? arg.url : true),
"When bridge is enabled, url must be set",
),
})
.default({
blocked: [],
@ -498,6 +504,7 @@ export const configValidator = z.object({
software: "lysand-ap",
allowed_ips: [],
token: "",
url: "",
},
}),
instance: z

View file

@ -305,8 +305,14 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
}
if (instance.data.protocol === "activitypub") {
// Placeholder for ActivityPub user fetching
throw new Error("ActivityPub user fetching not implemented");
const bridgeUri = new URL(
`/apbridge/lysand/query?${new URLSearchParams({
user_url: uri,
})}`,
config.federation.bridge.url,
);
return await User.saveFromLysand(bridgeUri.toString(), instance);
}
throw new Error(`Unsupported protocol: ${instance.data.protocol}`);