-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
70,143 additions
and
29,418 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 105 additions & 0 deletions
105
src/api/routes/guilds/automations/email-domain-lookup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/util/schemas/responses/EmailDomainLookupVerifyCodeResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.