diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index e303053c..c76df782 100644
--- a/src/api/routes/channels/#channel_id/messages/index.ts
+++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -406,6 +406,7 @@ router.post(
);
setImmediate(async () => {
+ if (!Config.get().federation.enabled) return;
const ap = await transformMessageToAnnounceNoce(message);
await Federation.distribute(ap);
diff --git a/src/api/routes/guilds/#guild_id/welcome-screen.ts b/src/api/routes/guilds/#guild_id/welcome-screen.ts
index 81000b4b..f391d7bd 100644
--- a/src/api/routes/guilds/#guild_id/welcome-screen.ts
+++ b/src/api/routes/guilds/#guild_id/welcome-screen.ts
@@ -70,6 +70,14 @@ router.patch(
const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
+ // TODO: move this
+ if (!guild.welcome_screen)
+ guild.welcome_screen = {
+ enabled: false,
+ description: "",
+ welcome_channels: [],
+ };
+
if (body.enabled != undefined)
guild.welcome_screen.enabled = body.enabled;
diff --git a/src/api/routes/invites/index.ts b/src/api/routes/invites/index.ts
index e91215c4..fe983e11 100644
--- a/src/api/routes/invites/index.ts
+++ b/src/api/routes/invites/index.ts
@@ -19,9 +19,10 @@
import {
APError,
APObjectIsOrganisation,
- resolveWebfinger,
splitQualifiedMention,
transformOrganisationToInvite,
+ tryFederatedGuildJoin,
+ tryResolveWebfinger,
} from "@spacebar/ap";
import { route } from "@spacebar/api";
import {
@@ -68,14 +69,18 @@ router.get(
if (domain != accountDomain && domain != host) {
// The domain isn't ours
- const remoteGuild = await resolveWebfinger(inputValue);
+ const remoteGuild = await tryResolveWebfinger(inputValue);
+ if (remoteGuild) {
+ if (APObjectIsOrganisation(remoteGuild))
+ return res.json(
+ await transformOrganisationToInvite(
+ inputValue,
+ remoteGuild,
+ ),
+ );
- if (APObjectIsOrganisation(remoteGuild))
- return res.json(
- transformOrganisationToInvite(remoteGuild),
- );
-
- throw new APError("Remote resource is not a guild");
+ throw new APError("Remote resource is not a guild");
+ }
}
}
}
@@ -110,8 +115,21 @@ router.post(
}),
async (req: Request, res: Response) => {
if (req.user_bot) throw DiscordApiErrors.BOT_PROHIBITED_ENDPOINT;
-
const { code } = req.params;
+
+ // Federation
+ const mention = splitQualifiedMention(code);
+ if (mention.user.length && Config.get().federation.enabled) {
+ const { domain } = mention;
+ const { accountDomain, host } = Config.get().federation;
+ if (domain != accountDomain && domain != host) {
+ // this domain isn't ours, try a federated join
+ // send a follow request to the guild
+
+ return res.json(await tryFederatedGuildJoin(code, req.user_id));
+ }
+ }
+
const { guild_id } = await Invite.findOneOrFail({
where: { code: code },
});
|