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: Generic webhook #8057

Closed
wants to merge 4 commits into from

Conversation

martynvdijke
Copy link

@martynvdijke martynvdijke commented Sep 17, 2024

⚠️ Pre Checklist

Please complete ALL items in this checklist, and remove before submitting

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

This PR tries to implement #7765 by adding a generic webhook to push any generic/custom data into the database.
Currently WIP, I am struggling to correctly save the information to database looking for feedback to make the code better.

Does this close any open issues?

#7765

Screenshots

Include any relevant screenshots here.

Other Information

Any other information that is important to this PR.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. component/plugins This issue or PR relates to plugins pr-type/feature-development This PR is to develop a new feature labels Sep 17, 2024
@klesh klesh requested a review from d4x1 September 18, 2024 02:24
@d4x1
Copy link
Contributor

d4x1 commented Sep 18, 2024

Nice work!

@martynvdijke martynvdijke marked this pull request as draft October 2, 2024 14:28
@martynvdijke
Copy link
Author

Anybody that could have a look at this and help me out ?

type WebhookGenericReq struct {
Title string `mapstructure:"title" validate:"required"`
Description string `mapstructure:"description"`
Data map[string]interface{} `mapstructure:"json"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the mapstructure tag value should be data. Is it a typo?


err = api.DecodeMapStruct(input.Body, request, true)
if err != nil {
return &plugin.ApiResourceOutput{Body: err.Error(), Status: http.StatusBadRequest}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just return err as the second returned value.

generic.Title = request.Title
generic.Description = request.Description
generic.CreatedDate = request.CreatedDate
generic.Data = fmt.Sprintf("%s", request.Data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work? I am not sure.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Feb 13, 2025
Copy link

This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.

@github-actions github-actions bot closed this Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugins This issue or PR relates to plugins pr-type/feature-development This PR is to develop a new feature size:L This PR changes 100-499 lines, ignoring generated files. Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants