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

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

Merged
merged 6 commits into from
Nov 22, 2023

Conversation

Kshitij-Katiyar
Copy link
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
@mattermost-build
Copy link
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
Copy link

codecov-commenter commented Apr 4, 2023

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.

Copy link
Contributor

@m1lt0n m1lt0n left a comment

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
@@ -25,6 +26,11 @@ const (
featureStars = "stars"
)

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
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
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
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.

server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/command.go Outdated Show resolved Hide resolved
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
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
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.

server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/plugin.go Outdated Show resolved Hide resolved
…#29)

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

* [MI-2998]:Fixed self review comments
@hanzei hanzei requested review from mickmister and removed request for hanzei April 23, 2023 20:17
Copy link
Member

@mickmister mickmister left a comment

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 👍

server/plugin/command.go Outdated Show resolved Hide resolved
@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
@mattermost-build
Copy link
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
Copy link
Contributor

hanzei commented May 9, 2023

/update-branch

@mattermost-build
Copy link
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
@@ -25,6 +26,11 @@ const (
featureStars = "stars"
)

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
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.

server/plugin/command.go Outdated Show resolved Hide resolved
@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
server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/command.go Outdated Show resolved Hide resolved
@hanzei hanzei removed their request for review August 8, 2023 11:23
@hanzei hanzei removed their request for review August 8, 2023 12:24
@hanzei
Copy link
Contributor

hanzei commented Aug 8, 2023

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

Copy link
Contributor

@hanzei hanzei left a comment

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
@DHaussermann
Copy link

@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

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
Member

@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
9 checks passed
@mickmister
Copy link
Member

@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

@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