mattermost / mattermost-plugin-github

GitHub plugin for Mattermost
Apache License 2.0
157 stars 150 forks source link

Fix PR subscription error "You cannot update an existing Post" #755

Closed mickmister closed 4 months ago

mickmister commented 6 months ago

Summary

This PR fixes an issue in the pull request event webhook logic where we reuse the same post struct for multiple calls to CreatePost, resulting in this error:

CreatePost: You cannot update an existing Post.

This PR applies a fix to make it so we instantiate a Post struct in the subscriptions loop, and only when we are going to create a post for that given subscription for the most part.

Ticket Link

Fixes https://github.com/mattermost/mattermost-plugin-github/issues/754

codecov-commenter commented 6 months ago

Codecov Report

Attention: Patch coverage is 0% with 68 lines in your changes are missing coverage. Please review.

Project coverage is 16.16%. Comparing base (da4c4df) to head (e6c087f). Report is 3 commits behind head on master.

:exclamation: Current head e6c087f differs from pull request most recent head 35851e2

Please upload reports for the commit 35851e2 to get more accurate results.

Files Patch % Lines
server/plugin/webhook.go 0.00% 68 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #755 +/- ## ======================================= Coverage 16.16% 16.16% ======================================= Files 17 17 Lines 6021 6021 ======================================= Hits 973 973 Misses 5003 5003 Partials 45 45 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Kshitij-Katiyar commented 4 months ago

@mickmister Can we please fix the lint errors here ?

mickmister commented 4 months ago

@AayushChaudhary0001 Can you take a look at this PR when you have the chance? Essentially all webhook events need to be tested