implement hubs routes
This commit is contained in:
parent
dd52fbf14b
commit
8c7fabfe40
2894
assets/openapi.json
2894
assets/openapi.json
File diff suppressed because it is too large
Load Diff
341291
assets/schemas.json
341291
assets/schemas.json
File diff suppressed because it is too large
Load Diff
11
package-lock.json
generated
11
package-lock.json
generated
@ -20,6 +20,7 @@
|
||||
"cheerio": "^1.0.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"dotenv": "^16.4.5",
|
||||
"email-providers": "^2.7.0",
|
||||
"exif-be-gone": "^1.5.1",
|
||||
"fast-zlib": "^2.0.1",
|
||||
"fido2-lib": "^3.5.3",
|
||||
@ -45,6 +46,7 @@
|
||||
"probe-image-size": "^7.2.3",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"sqlite3": "^5.1.7",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.8.0",
|
||||
"typeorm": "^0.3.20",
|
||||
@ -5616,6 +5618,15 @@
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/email-providers": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/email-providers/-/email-providers-2.7.0.tgz",
|
||||
"integrity": "sha512-WAkVYZnrXN659hOem4B5qsQl7uRTqFhljjLjAdpO6te/dAbeMa708Tf7WwgHtCnXjl54HC4ojjPA9wq4NloKqQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
@ -80,6 +80,7 @@
|
||||
"cheerio": "^1.0.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"dotenv": "^16.4.5",
|
||||
"email-providers": "^2.7.0",
|
||||
"exif-be-gone": "^1.5.1",
|
||||
"fast-zlib": "^2.0.1",
|
||||
"fido2-lib": "^3.5.3",
|
||||
|
41
src/api/routes/channels/#channel_id/directory-entries.ts
Normal file
41
src/api/routes/channels/#channel_id/directory-entries.ts
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { HubDirectoryEntriesResponse } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
"/",
|
||||
route({
|
||||
responses: {
|
||||
200: {
|
||||
body: "HubDirectoryEntriesResponse",
|
||||
},
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
res.json([] as HubDirectoryEntriesResponse);
|
||||
},
|
||||
);
|
||||
|
||||
export default router;
|
105
src/api/routes/guilds/automations/email-domain-lookup.ts
Normal file
105
src/api/routes/guilds/automations/email-domain-lookup.ts
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
EmailDomainLookupResponse,
|
||||
EmailDomainLookupSchema,
|
||||
EmailDomainLookupVerifyCodeSchema,
|
||||
FieldErrors,
|
||||
} from "@spacebar/util";
|
||||
import emailProviders from "email-providers/all.json";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
"/",
|
||||
route({
|
||||
requestBody: "EmailDomainLookupSchema",
|
||||
responses: {
|
||||
200: {
|
||||
body: "EmailDomainLookupResponse",
|
||||
},
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
const { email } = req.body as EmailDomainLookupSchema;
|
||||
|
||||
const [_, tld] = email.split("@");
|
||||
|
||||
if (emailProviders.includes(tld.toLowerCase())) {
|
||||
throw FieldErrors({
|
||||
name: {
|
||||
message:
|
||||
"That looks like a personal email address. Please use your official student email.",
|
||||
code: "EMAIL_IS_UNOFFICIAL",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return res.json({
|
||||
guilds_info: [],
|
||||
has_matching_guild: false,
|
||||
} as EmailDomainLookupResponse);
|
||||
},
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/verify-code",
|
||||
route({
|
||||
requestBody: "EmailDomainLookupVerifyCodeSchema",
|
||||
responses: {
|
||||
// 200: {
|
||||
// body: "EmailDomainLookupVerifyCodeResponse",
|
||||
// },
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
},
|
||||
501: {},
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
const { email } = req.body as EmailDomainLookupVerifyCodeSchema;
|
||||
|
||||
const [_, tld] = email.split("@");
|
||||
|
||||
if (emailProviders.includes(tld.toLowerCase())) {
|
||||
throw FieldErrors({
|
||||
name: {
|
||||
message:
|
||||
"That looks like a personal email address. Please use your official student email.",
|
||||
code: "EMAIL_IS_UNOFFICIAL",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
throw new HTTPError("Not implemented", 501);
|
||||
|
||||
// return res.json({
|
||||
// guild: null,
|
||||
// joined: false,
|
||||
// } as EmailDomainLookupVerifyCodeResponse);
|
||||
},
|
||||
);
|
||||
|
||||
export default router;
|
52
src/api/routes/hub-waitlist.ts
Normal file
52
src/api/routes/hub-waitlist.ts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
HubWaitlistSignupResponse,
|
||||
HubWaitlistSignupSchema,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
"/signup",
|
||||
route({
|
||||
requestBody: "HubWaitlistSignupSchema",
|
||||
responses: {
|
||||
200: {
|
||||
body: "HubWaitlistSignupResponse",
|
||||
},
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
const { email, school } = req.body as HubWaitlistSignupSchema;
|
||||
|
||||
res.json({
|
||||
email,
|
||||
email_domain: email.split("@")[1],
|
||||
school,
|
||||
user_id: req.user_id,
|
||||
} as HubWaitlistSignupResponse);
|
||||
},
|
||||
);
|
||||
|
||||
export default router;
|
24
src/util/schemas/EmailDomainLookupSchema.ts
Normal file
24
src/util/schemas/EmailDomainLookupSchema.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface EmailDomainLookupSchema {
|
||||
allow_multiple_guilds: boolean;
|
||||
email: string;
|
||||
use_verification_code: boolean;
|
||||
guild_id?: string;
|
||||
}
|
23
src/util/schemas/EmailDomainLookupVerifyCodeSchema.ts
Normal file
23
src/util/schemas/EmailDomainLookupVerifyCodeSchema.ts
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface EmailDomainLookupVerifyCodeSchema {
|
||||
email: string;
|
||||
guild_id: string;
|
||||
code: string;
|
||||
}
|
22
src/util/schemas/HubWaitlistSignupSchema.ts
Normal file
22
src/util/schemas/HubWaitlistSignupSchema.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface HubWaitlistSignupSchema {
|
||||
email: string;
|
||||
school: string;
|
||||
}
|
@ -34,6 +34,8 @@ export * from "./ConnectedAccountSchema";
|
||||
export * from "./ConnectionCallbackSchema";
|
||||
export * from "./ConnectionUpdateSchema";
|
||||
export * from "./DmChannelCreateSchema";
|
||||
export * from "./EmailDomainLookupSchema";
|
||||
export * from "./EmailDomainLookupVerifyCodeSchema";
|
||||
export * from "./EmojiCreateSchema";
|
||||
export * from "./EmojiModifySchema";
|
||||
export * from "./ForgotPasswordSchema";
|
||||
@ -42,6 +44,7 @@ export * from "./GuildCreateSchema";
|
||||
export * from "./GuildTemplateCreateSchema";
|
||||
export * from "./GuildUpdateSchema";
|
||||
export * from "./GuildUpdateWelcomeScreenSchema";
|
||||
export * from "./HubWaitlistSignupSchema";
|
||||
export * from "./IdentifySchema";
|
||||
export * from "./InviteCreateSchema";
|
||||
export * from "./LazyRequestSchema";
|
||||
@ -59,6 +62,7 @@ export * from "./RegisterSchema";
|
||||
export * from "./RelationshipPostSchema";
|
||||
export * from "./RelationshipPutSchema";
|
||||
export * from "./RequestGuildMembersSchema";
|
||||
export * from "./responses";
|
||||
export * from "./RoleModifySchema";
|
||||
export * from "./RolePositionUpdateSchema";
|
||||
export * from "./SelectProtocolSchema";
|
||||
@ -83,4 +87,3 @@ export * from "./WebAuthnSchema";
|
||||
export * from "./WebhookCreateSchema";
|
||||
export * from "./WebhookExecuteSchema";
|
||||
export * from "./WidgetModifySchema";
|
||||
export * from "./responses";
|
||||
|
27
src/util/schemas/responses/EmailDomainLookupResponse.ts
Normal file
27
src/util/schemas/responses/EmailDomainLookupResponse.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface HubGuild {
|
||||
icon: string;
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface EmailDomainLookupResponse {
|
||||
guilds_info: HubGuild[];
|
||||
has_matching_guild: boolean;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Guild } from "../../entities";
|
||||
|
||||
export interface EmailDomainLookupVerifyCodeResponse {
|
||||
guild: Guild;
|
||||
joined: boolean;
|
||||
}
|
31
src/util/schemas/responses/HubDirectoryEntriesResponse.ts
Normal file
31
src/util/schemas/responses/HubDirectoryEntriesResponse.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Guild } from "../../entities";
|
||||
|
||||
export interface HubDirectoryEntry {
|
||||
author_id: string;
|
||||
created_at: string;
|
||||
description: string;
|
||||
directory_channel_id: string;
|
||||
guild: Guild;
|
||||
primary_category_id: number;
|
||||
type: number; // TODO: not exactly sure what this is, channel type?
|
||||
}
|
||||
|
||||
export type HubDirectoryEntriesResponse = HubDirectoryEntry[];
|
24
src/util/schemas/responses/HubWaitlistSignupResponse.ts
Normal file
24
src/util/schemas/responses/HubWaitlistSignupResponse.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface HubWaitlistSignupResponse {
|
||||
email: string;
|
||||
email_domain: string;
|
||||
school: string;
|
||||
user_id: string;
|
||||
}
|
@ -21,6 +21,8 @@ export * from "./APIErrorResponse";
|
||||
export * from "./BackupCodesChallengeResponse";
|
||||
export * from "./CaptchaRequiredResponse";
|
||||
export * from "./DiscoverableGuildsResponse";
|
||||
export * from "./EmailDomainLookupResponse";
|
||||
export * from "./EmailDomainLookupVerifyCodeResponse";
|
||||
export * from "./GatewayBotResponse";
|
||||
export * from "./GatewayResponse";
|
||||
export * from "./GenerateRegistrationTokensResponse";
|
||||
@ -34,6 +36,8 @@ export * from "./GuildVanityUrl";
|
||||
export * from "./GuildVoiceRegionsResponse";
|
||||
export * from "./GuildWidgetJsonResponse";
|
||||
export * from "./GuildWidgetSettingsResponse";
|
||||
export * from "./HubDirectoryEntriesResponse";
|
||||
export * from "./HubWaitlistSignupResponse";
|
||||
export * from "./InstanceDomainsResponse";
|
||||
export * from "./InstancePingResponse";
|
||||
export * from "./InstanceStatsResponse";
|
||||
@ -47,7 +51,7 @@ export * from "./TypedResponses";
|
||||
export * from "./UpdatesResponse";
|
||||
export * from "./UserNoteResponse";
|
||||
export * from "./UserProfileResponse";
|
||||
export * from "./UserRelationsResponse";
|
||||
export * from "./UserRelationshipsResponse";
|
||||
export * from "./UserRelationsResponse";
|
||||
export * from "./WebAuthnCreateResponse";
|
||||
export * from "./WebhookCreateResponse";
|
||||
|
Loading…
x
Reference in New Issue
Block a user