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
[WIP] webhooks/codebase: Implementing Codebase Webhook using Event Hook API. #12260
base: main
Are you sure you want to change the base?
Conversation
d17ae4e
to
6eea43d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sameerchoubey: Thanks for working on this! I just left a few comments. Also, I would recommend fixing the build errors and amending the commit message to be webhooks/codebase: Add Event Hook API implementation.
:)
Cheers! :)
|
||
1. Go to your Codebase Dashboard, and click on the settings icon in | ||
the top-right corner. Click on **Event Hooks**. | ||
Now, click **New Event Webhook**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would join the last two sentences together, Click on **Event Hooks**, and click **New Event Webhook**.
It reads better, imo!
name = payload['user']['name'] | ||
url = payload['ticket']['project']['url'] | ||
|
||
body = "Ticket with ID **[{}]({})**, category **{}** has been updated by **{}**".format(id, url, type, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things:
- I would move both body template strings to the top of the file with all uppercase names, such as
TICKET_UPDATE_TEMPLATE
. I would also use named format arguments, such as"has been updated by {author}".format(author=author)
- Also, I would recommend ending all messages with proper punctuation, i.e., a period. I am currently doing an audit to make sure we use proper punctuation across all of our webhooks.
payload = payload['payload'] | ||
payload = json.loads(payload) | ||
|
||
type = payload['type']['name'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type
is a reserved Python keyword, I would replace this with something like ticket_type
.
payload = json.loads(payload) | ||
|
||
id = payload['ticket']['id'] | ||
type = payload['ticket']['category'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both id
and type
are reserved keywords in Python, it is a good habit to use descriptive alternatives such as ticket_type
or ticket_id
instead!
payload: Dict[str, Iterable[Dict[str, Any]]]=REQ(argument_type='body') | ||
) -> HttpResponse: | ||
|
||
if payload is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. is the payload every actually None
? I would be surprised if it is.
@eeshangarg Yeah. I'll make these changes and also add other events. Thanks for reviewing. |
6eea43d
to
65d2f44
Compare
Heads up @sameerchoubey, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
4ec3636
to
88b200c
Compare
This PR currently add support for two events.
ticket_creation
andticket_update
@eeshangarg Can you please look at this?
Fixes #9395