Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webhooks): allow client registration through env #118

Conversation

daywiss
Copy link
Contributor

@daywiss daywiss commented Nov 27, 2024

motivation

we need an easy way to add and update arbitrary webhook clients

changes

this adds env config var to regsiter new clients as well as removes domain checks to make it easier for testing

Signed-off-by: david <david@umaproject.org>
Copy link

linear bot commented Nov 27, 2024

// assert(
// isDomainValid,
// "The base URL of the provided webhook does not match any of the client domains",
// );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed domain checking for now

@@ -2,6 +2,7 @@ import { Entity, Column, PrimaryGeneratedColumn, Unique } from "typeorm";

@Entity()
@Unique("UK_webhook_client_api_key", ["apiKey"])
@Unique("UK_webhook_client_name", ["name"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wnated to make a unique constraint for name, i dont know if i did this right because i have no idea what UK_webhook means

@@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class Webhook1732730161339 implements MigrationInterface {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did the migration after adding uniquye name constraint, again dont know if this is correct

Copy link
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I'm a bit confused on this but shouldn't CB be able to register their own client hooks?

@@ -87,10 +87,12 @@ export async function Main(
const postgres = await connectToDatabase(postgresConfig, logger);
const redisConfig = Indexer.parseRedisConfig(env);
const redis = await initializeRedis(redisConfig, logger);
const webhooks = Webhooks.WebhookFactory(
const webhooks = await Webhooks.WebhookFactory(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually a factory is a class that has a builder function on it. Is this Factory a function?

Copy link
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as this runs the code looks fine outside of stylizations

@daywiss daywiss merged commit f0ca94a into master Nov 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants