Skip to content

11311 object create webhook should be triggered when object is created via rest api #11336

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

Conversation

martmull
Copy link
Contributor

@martmull martmull commented Apr 2, 2025

Fixes #11311

@martmull martmull force-pushed the 11311-object-create-webhook-should-be-triggered-when-object-is-created-via-rest-api branch from a07b80f to 26f66f5 Compare April 2, 2025 07:58
@martmull martmull marked this pull request as ready for review April 2, 2025 08:01
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The PR integrates webhook triggers for create, update, and delete operations in the REST API, aligning with GraphQL event handling by standardizing event types to TypeORM's ObjectLiteral.

  • Updated type usage in /packages/twenty-server/src/engine/api/graphql/graphql-query-runner/services/api-event-emitter.service.ts to use ObjectLiteral for all event actions.
  • Integrated ApiEventEmitterService in /packages/twenty-server/src/engine/api/rest/core/rest-api-core-v2.service.ts to emit webhooks post-create, update, and delete, relying on AuthContext.
  • Adjusted /packages/twenty-server/src/engine/api/rest/rest-api.module.ts by removing deprecated dependencies and registering ApiEventEmitterService for webhook support.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@martmull martmull force-pushed the 11311-object-create-webhook-should-be-triggered-when-object-is-created-via-rest-api branch 3 times, most recently from 71897fd to 2068043 Compare April 2, 2025 08:13
@martmull martmull force-pushed the 11311-object-create-webhook-should-be-triggered-when-object-is-created-via-rest-api branch from 2068043 to 783fcc3 Compare April 2, 2025 08:14
await this.getRepositoryAndMetadataOrFail(request);
const createdRecord = await repository.save(body);

const authContext = this.getAuthContextFromRequest(request);

if (authContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Shouldn't this be an invariant ? Isn't the route guarded by authentication ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, workspace was optional but there is no reason for that

@martmull martmull enabled auto-merge (squash) April 2, 2025 08:15
@martmull martmull disabled auto-merge April 2, 2025 08:16
@martmull martmull merged commit 6e92b19 into main Apr 2, 2025
32 checks passed
@martmull martmull deleted the 11311-object-create-webhook-should-be-triggered-when-object-is-created-via-rest-api branch April 2, 2025 08:22
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.

Object Create webhook should be triggered when object is created via Rest Api
3 participants