diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-24 18:15:26 +1100 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-03-18 19:33:32 -0400 |
commit | c7277efbad5d3979222518ae543366ba8a08ca77 (patch) | |
tree | 89f9815b7c2a66908874eb0f2eb678aeb0211a96 /src/util/connections | |
parent | Check visibility for connected accounts in /users/:id/profile (diff) | |
download | server-c7277efbad5d3979222518ae543366ba8a08ca77.tar.xz |
Move redirect uri generation to getRedirectUri function of Connection class.
Use api_endpointPublic instead of cdn_endpointPublic
Diffstat (limited to 'src/util/connections')
-rw-r--r-- | src/util/connections/Connection.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/connections/Connection.ts b/src/util/connections/Connection.ts index 8b60b0d2..26279299 100644 --- a/src/util/connections/Connection.ts +++ b/src/util/connections/Connection.ts @@ -1,7 +1,7 @@ import crypto from "crypto"; import { ConnectedAccount } from "../entities"; import { ConnectedAccountSchema, ConnectionCallbackSchema } from "../schemas"; -import { DiscordApiErrors } from "../util"; +import { Config, DiscordApiErrors } from "../util"; /** * A connection that can be used to connect to an external service. @@ -20,6 +20,16 @@ export default abstract class Connection { abstract getAuthorizationUrl(userId: string): string; /** + * Returns the redirect_uri for a connection type + * @returns redirect_uri for this connection + */ + getRedirectUri() { + const endpointPublic = + Config.get().api.endpointPublic ?? "http://localhost:3001"; + return `${endpointPublic}/connections/${this.id}/callback`; + } + + /** * Processes the callback * @param args Callback arguments */ |