mattermost-plugin-github icon indicating copy to clipboard operation
mattermost-plugin-github copied to clipboard

Mm 379 - Add a feature to configure the webhook with the command itself

Open maisnamrajusingh opened this issue 4 years ago • 21 comments

Summary

ability to configure the webhook using a command

Ticket Link

https://github.com/mattermost/mattermost-plugin-github/issues/379

maisnamrajusingh avatar Jul 13 '21 09:07 maisnamrajusingh

Hello @maisnamrajusingh,

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.

mattermod avatar Jul 13 '21 09:07 mattermod

@hanzei Ignore the request, please.This still has some linting issues

maisnamrajusingh avatar Jul 13 '21 09:07 maisnamrajusingh

Codecov Report

Merging #456 (9b87a40) into master (431bac0) will decrease coverage by 0.79%. The diff coverage is 6.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #456      +/-   ##
==========================================
- Coverage   18.49%   17.69%   -0.80%     
==========================================
  Files          12       12              
  Lines        3320     3549     +229     
==========================================
+ Hits          614      628      +14     
- Misses       2667     2882     +215     
  Partials       39       39              
Impacted Files Coverage Δ
server/plugin/command.go 6.65% <0.00%> (-2.11%) :arrow_down:
server/plugin/webhook.go 0.00% <0.00%> (ø)
server/plugin/plugin.go 4.08% <16.66%> (+0.19%) :arrow_up:
server/plugin/template.go 95.45% <100.00%> (+0.23%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 431bac0...9b87a40. Read the comment docs.

codecov-commenter avatar Jul 13 '21 13:07 codecov-commenter

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!

/cc @jasonblais @jfrerich @emilyacook

mattermod avatar Aug 02 '21 01:08 mattermod

@hanzei kind reminder to help with review

jasonblais avatar Aug 05 '21 15:08 jasonblais

@hanzei Is there a benefit to setting up webhooks via plugin other than for the subscriptions feature? If not, I propose we keep the webhooks an implementation detail and have the plugin handle the logistics of webhooks. See my comment here https://github.com/mattermost/mattermost-plugin-github/pull/466#discussion_r685694061

mickmister avatar Aug 10 '21 05:08 mickmister

@hanzei can you check on comments made and let me know

sibasankarnayak avatar Nov 11 '21 15:11 sibasankarnayak

@sibasankarnayak What comments are you referring to? I don't see an answer from you to the comment I've made in https://github.com/mattermost/mattermost-plugin-github/pull/456#pullrequestreview-803612426.

hanzei avatar Nov 15 '21 12:11 hanzei

@sibasankarnayak What comments are you referring to? I don't see an answer from you to the comment I've made in #456 (review).

@hanzei not sure why the commets were in pending state , can you check now

sibasankarnayak avatar Nov 15 '21 14:11 sibasankarnayak

@mickmister @hanzei

have added the org scope for oauth to manage in org level webhook ,let me know the review on this

sibasankarnayak avatar Dec 02 '21 17:12 sibasankarnayak

@hanzei @mickmister and i had a discussion on command /github webhook list org/[repo] , github won't allow us to add duplicate webhook so ultimately it is just one webhook every time and for getting that webhook we currently fetch all and filter out on basis on webhook call back url , so need you input on this should we keep the list command . michael had a suggestion for changing the command to /github webhook check org/repo.

sibasankarnayak avatar Dec 03 '21 06:12 sibasankarnayak

Two comments from testing the feature:

  1. Can we improve the UX for users who didn't run the connect command again to approve the new scopes? Right now, they only get an error message.
  2. I still can't get the feature working. The error message I get is Screenshot from 2021-12-03 09-14-21

but the OAuth App is already approved: Screenshot from 2021-12-03 09-14-39

Is there anything that I need to enable?

  1. Running a per-repo command still returns a 404. Is that related to 2.?

@hanzei getting 404 error indicates the repo or org you are trying is not reachable , can you try to revoke all the user from the OAuth and try to disconnect and then connect . this should work.

sibasankarnayak avatar Dec 03 '21 11:12 sibasankarnayak

michael had a suggestion for changing the command to /github webhook check org/repo.

Sorry when I said "It seems like it should be /webhook check org/repo since we're only expecting at most one webhook right?" I meant that if we had this exact same command that it seems like it should be named that. Based on our conversation, I'm not necessarily suggesting that we have the command that takes the org/repo at all.

I like the idea of storing the webhooks created through the plugin and using that to list out the commands as suggested here https://github.com/mattermost/mattermost-plugin-github/pull/456#discussion_r761304353. We do need to take into account webhooks that have been deleted using the GitHub UI though. So we should check GitHub's API whenever the /github webhook list command is run, and remove webhook entries from the kv store that we find out have been deleted.

mickmister avatar Dec 03 '21 15:12 mickmister

michael had a suggestion for changing the command to /github webhook check org/repo.

Sorry when I said "It seems like it should be /webhook check org/repo since we're only expecting at most one webhook right?" I meant that if we had this exact same command that it seems like it should be named that. Based on our conversation, I'm not necessarily suggesting that we have the command that takes the org/repo at all.

I like the idea of storing the webhooks created through the plugin and using that to list out the commands as suggested here #456 (comment). We do need to take into account webhooks that have been deleted using the GitHub UI though. So we should check GitHub's API whenever the /github webhook list command is run, and remove webhook entries from the kv store that we find out have been deleted.

@mickmister just came accross this situation where user have already created the webhook manually and it points to mmSiteUrl , are we going to fetch the hook details and then storing it in KVStore ?

cc @hanzei

sibasankarnayak avatar Dec 06 '21 13:12 sibasankarnayak

@hanzei @mickmister have tried to store the webhook details in KVstore , please share feedback

sibasankarnayak avatar Dec 06 '21 17:12 sibasankarnayak

We talked offline about improving the UX if a user hasn't consented to new list of scopes yet. Was there any progress about that idea?

@hanzei i have got some , can have a look on this https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps

sibasankarnayak avatar Dec 30 '21 17:12 sibasankarnayak

We talked offline about improving the UX if a user hasn't consented to new list of scopes yet. Was there any progress about that idea?

@hanzei i have got some , can have a look on this https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps

this is the screenshot of message on insufficient scope , can you help me with the message for better ux

image

sibasankarnayak avatar Dec 31 '21 03:12 sibasankarnayak

@maisnamrajusingh Is it enough to /github connect without calling /github disconnect before?

hanzei avatar Jan 04 '22 13:01 hanzei

@maisnamrajusingh Is it enough to /github connect without calling /github disconnect before?

@hanzei yes we can directly use /github connect and it does replaces the scope

and one more thing i have a suggestion from my side

when the repo or org is invalid we get such error image

instead of this we can have some meaningful error like invalid org/repo name as we have already able to figure if the error is because of scope

sibasankarnayak avatar Jan 05 '22 13:01 sibasankarnayak

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!

/cc @aspleenic

mattermod avatar Jan 17 '22 01:01 mattermod

This work conflicts with the work on the growth spike. Hence, work on it should stop for now.

hanzei avatar Jan 18 '22 13:01 hanzei

https://github.com/mattermost/mattermost-plugin-github/issues/379#issuecomment-1437213625

hanzei avatar Feb 21 '23 18:02 hanzei