summary refs log tree commit diff
path: root/src/util/connections
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-01-24 18:15:26 +1100
committerPuyodead1 <puyodead@proton.me>2023-03-18 19:33:32 -0400
commitc7277efbad5d3979222518ae543366ba8a08ca77 (patch)
tree89f9815b7c2a66908874eb0f2eb678aeb0211a96 /src/util/connections
parentCheck visibility for connected accounts in /users/:id/profile (diff)
downloadserver-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.ts12
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
 	 */