Skip to content

[GH-378]:Fixed issue #378 'Check for webhook while subscribing' - #664

Merged
mickmister merged 6 commits into
mattermost:masterfrom
Brightscout:MM-378
Nov 22, 2023
Merged

[GH-378]:Fixed issue #378 'Check for webhook while subscribing'#664
mickmister merged 6 commits into
mattermost:masterfrom
Brightscout:MM-378

Conversation

@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

Summary

  • When a user creates a subscription to a repo the plugin is now checking the repo (or parent Organization for Enterprise) to see if a webhook is in place to deliver the events.

  • If no webhook is found on the GitHub side, an ephemeral post is sent to remind the user that a webhook must be set up..

  • Issue #378

…bing' (#28)

* [MI-2935]:Fixed issue mattermost#378 'Check for webhook while subscribing'

* [MI-2935]:Fixed self review comments

* [MI-2935]:Updated the message

* [MI-2935]:Fixed review comments

* [MI-2935]:Fixed lint errors

* [MI-2935]:Fixed review comments
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei as a code owner April 4, 2023 10:59
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from m1lt0n April 4, 2023 10:59
@mattermost-build

Copy link
Copy Markdown
Contributor

Hello @Kshitij-Katiyar,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@codecov-commenter

codecov-commenter commented Apr 4, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage has no change and project coverage change: -0.23 ⚠️

Comparison is base (757c9c1) 15.54% compared to head (a963985) 15.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #664      +/-   ##
==========================================
- Coverage   15.54%   15.32%   -0.23%     
==========================================
  Files          15       15              
  Lines        5473     5548      +75     
==========================================
- Hits          851      850       -1     
- Misses       4579     4656      +77     
+ Partials       43       42       -1     
Impacted Files Coverage Δ
server/plugin/command.go 7.50% <0.00%> (-0.65%) ⬇️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@m1lt0n m1lt0n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally and the check & message changes seem to work properly

@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Apr 11, 2023
@hanzei hanzei linked an issue Apr 11, 2023 that may be closed by this pull request
Comment thread server/plugin/command.go Outdated

const (
ErrorNoWebhookFound = "\nNo webhook was found for this repository or organization. To create one, enter the following slash command `/github setup webhook`"
GithubListOptionsPerPageValue = 50

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a const for perPage anywhere else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no there is no constant for this in the code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1/5 let's use a generic perPage here and in the rest of the code.

Comment thread server/plugin/command.go Outdated
Comment thread server/plugin/command.go Outdated
Comment thread server/plugin/command.go Outdated
Comment on lines +293 to +296
// Breaking from the loop if the repo or org is not found
if strings.Contains(err.Error(), "404 Not Found") {
isWebhook = true
break

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Breaking here de-facto means returning, right? Why is the 404 case special?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

404 case is special because we are checking whether there is an org or repo present with the name we put during subscribing if not we don't need any additional messages.

Comment thread server/plugin/command.go Outdated
Comment thread server/plugin/plugin.go Outdated
…#29)

* [MI-2998]:Fixed review comments of PR mattermost#664 on github plugin

* [MI-2998]:Fixed self review comments
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei April 17, 2023 12:29
@hanzei
hanzei requested review from mickmister and removed request for hanzei April 23, 2023 20:17

@mickmister mickmister left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one suggestion to rename a function. Otherwise LGTM 👍

Comment thread server/plugin/command.go Outdated
@mickmister mickmister added 3: QA Review Requires review by a QA tester and removed 2: Dev Review Requires review by a core committer labels Apr 25, 2023
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei April 26, 2023 07:44
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@hanzei

hanzei commented May 9, 2023

Copy link
Copy Markdown
Contributor

/update-branch

@mattermost-build

Copy link
Copy Markdown
Contributor

We don't have permissions to update this PR, please contact the submitter to apply the update.

@hanzei
hanzei requested review from DHaussermann and removed request for hanzei May 9, 2023 19:50
Comment thread server/plugin/command.go Outdated

const (
ErrorNoWebhookFound = "\nNo webhook was found for this repository or organization. To create one, enter the following slash command `/github setup webhook`"
GithubListOptionsPerPageValue = 50

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1/5 let's use a generic perPage here and in the rest of the code.

Comment thread server/plugin/command.go Outdated
@hanzei
hanzei removed the request for review from DHaussermann May 9, 2023 19:53
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label May 9, 2023
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei July 7, 2023 09:40
Comment thread server/plugin/command.go Outdated
Comment thread server/plugin/command.go Outdated
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei July 21, 2023 10:26
@hanzei
hanzei removed their request for review August 8, 2023 11:23
@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei August 8, 2023 12:13
@hanzei
hanzei removed their request for review August 8, 2023 12:24
@hanzei

hanzei commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

@Kshitij-Katiyar There is no need to re-request a review. That can be done once there is new code to review.

@Kshitij-Katiyar
Kshitij-Katiyar requested a review from hanzei August 9, 2023 10:20

@hanzei hanzei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome 🎉

@hanzei hanzei removed 2: Dev Review Requires review by a core committer Awaiting Submitter Action Blocked on the author Lifecycle/1:stale labels Aug 9, 2023
@hanzei
hanzei requested a review from DHaussermann August 9, 2023 12:16
@DHaussermann

Copy link
Copy Markdown

@Kshitij-Katiyar I did not have time to pull this into my work queue.

I'll keep myself asa reviewer for now. Please advise if this can be covered by a QA resource on the Brightscout side.

@Kshitij-Katiyar Kshitij-Katiyar added this to the v2.3.0 milestone Oct 5, 2023
@hanzei
hanzei removed the request for review from DHaussermann October 16, 2023 20:38
@hanzei hanzei mentioned this pull request Nov 9, 2023
@avas27JTG avas27JTG modified the milestones: v2.3.0, v2.2.0 Nov 13, 2023
@AayushChaudhary0001

Copy link
Copy Markdown

The PR has been tested and the actual result can be enhanced as the ephemeral post is getting merged with the warning message for the private repository.

Enhancement : A separate title for the ephemeral post can be added.

image

@mickmister

Copy link
Copy Markdown
Contributor

@matthewbirtch Do you have any thoughts on the screenshot and comment mentioned above?

@mickmister mickmister added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Nov 22, 2023
@mickmister
mickmister merged commit 1a1f668 into mattermost:master Nov 22, 2023
@mickmister

Copy link
Copy Markdown
Contributor

@AayushChaudhary0001 I see, the "No webhook was found" is blended into the same paragraph as the "private repository" warning. Maybe we should put the webhook message above, or have a "Note:" before the webhook message

@matthewbirtch

Copy link
Copy Markdown

@AayushChaudhary0001 I see, the "No webhook was found" is blended into the same paragraph as the "private repository" warning. Maybe we should put the webhook message above, or have a "Note:" before the webhook message

I agree that we shouldn't blend this note in with the warning paragraph.

I would also say that it doesn't quite feel right that we say "Successfully subscribed to {repo}", and then have a warning and a note about no webhook being found.

Maybe we consider adding the note to the first paragraph so it reads:

"Successfully subscribed to {repo}, but no webhook was found for this repository or organization. To create one, enter /github setup webhook"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4: Reviews Complete All reviewers have approved the pull request Contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub - Check for an existing webhook when subscribing to a repo

10 participants