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-512,513] Fixed issue #512 and #513 on github plugin 'Updated subscription success messages' #661

Merged
merged 11 commits into from
Nov 28, 2023

Conversation

Kshitij-Katiyar
Copy link
Contributor

Summary

  • If a user creates a new subscription for a repo or organization for which a subscription already exists, the events of the previous subscription get overwritten. So now added the list of events that got overwritten in the subscription message.

  • Added additional information like the username, events, etc in the subscription message.

  • Issue #512

  • Issue #513

…gin (#25)

* [MI-2904]:Fixed issue mattermost#512 and mattermost#513 on github plugin

* [MI-2904]:Fixed review comments

* [MI-2904]: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.

@Kshitij-Katiyar Kshitij-Katiyar changed the title [GH-512,513] Fixed issue #512 and #513 on github plugin [GH-512,513] Fixed issue #512 and #513 on github plugin 'Updated subscription success messages' Mar 23, 2023
server/plugin/command.go Outdated Show resolved Hide resolved
@@ -266,15 +287,14 @@ func (p *Plugin) handleSubscriptionsList(_ *plugin.Context, args *model.CommandA
}

func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, parameters []string, userInfo *GitHubUserInfo) string {
defaultEvents := Features("pulls,issues,creates,deletes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should even be a global variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

(suggestion) perhaps defaultEvents is a bit misleading, as it's a mutable variable that can change later on in the function, so it's not always holding the default events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hanzei I don't think so there is a need for making this variable global as we are only using this in this function.
@m1lt0n Changed the name for this variable.

server/plugin/command.go Outdated Show resolved Hide resolved
@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Mar 23, 2023
server/plugin/command.go Outdated Show resolved Hide resolved
@@ -266,15 +287,14 @@ func (p *Plugin) handleSubscriptionsList(_ *plugin.Context, args *model.CommandA
}

func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, parameters []string, userInfo *GitHubUserInfo) string {
defaultEvents := Features("pulls,issues,creates,deletes")
Copy link
Contributor

Choose a reason for hiding this comment

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

(suggestion) perhaps defaultEvents is a bit misleading, as it's a mutable variable that can change later on in the function, so it's not always holding the default events.

server/plugin/command.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2023

Codecov Report

Attention: 119 lines in your changes are missing coverage. Please review.

Comparison is base (573e4a3) 15.70% compared to head (047d2e0) 15.42%.

❗ Current head 047d2e0 differs from pull request most recent head a20d986. Consider uploading reports for the commit a20d986 to get more accurate results

Files Patch % Lines
server/plugin/command.go 0.00% 104 Missing ⚠️
server/plugin/subscriptions.go 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #661      +/-   ##
==========================================
- Coverage   15.70%   15.42%   -0.29%     
==========================================
  Files          15       15              
  Lines        5660     5595      -65     
==========================================
- Hits          889      863      -26     
+ Misses       4729     4690      -39     
  Partials       42       42              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@m1lt0n m1lt0n requested review from mickmister and removed request for m1lt0n March 24, 2023 13:52
Copy link
Contributor

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

Mostly LGTM, mainly just a few requests for readability. Thanks @Kshitij-Katiyar!

server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/command.go Outdated Show resolved Hide resolved
}

func (p *Plugin) getSubscribedFeatures(channelID, owner, repo string) (Features, error) {
var previousFeatures Features
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this named previousFeatures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are Features or events of an subscription which are going to be overwritten due to creation of new subscription.

msg := fmt.Sprintf("Successfully subscribed to [%s](%s).", repo, repoLink)
msg := fmt.Sprintf("@%v subscribed this channel to [%s/%s](%s) with the following events: %s", user.Username, owner, repo, repoLink, subscriptionEvents.FormattedString())
if previousSubscribedEvents != "" {
msg += previousSubscribedEventMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a space between the two concatenated strings? Same for other concatenations here in this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mickmister This is how it looks
Screenshot from 2023-03-28 10-38-43
Screenshot from 2023-03-28 10-39-00

server/plugin/command.go Outdated Show resolved Hide resolved
server/plugin/command.go Outdated Show resolved Hide resolved
Comment on lines 370 to 380
subscriptionSuccess := fmt.Sprintf("@%v subscribed this channel to [%s](%s) with the following events: %s.", user.Username, owner, orgLink, subscriptionEvents.FormattedString())

if previousSubscribedEvents != "" {
subscriptionSuccess += previousSubscribedEventMessage
}

return fmt.Sprintf("Successfully subscribed to organization %s.", owner)
if appErr = p.CreatePost(args.ChannelId, p.BotUserID, subscriptionSuccess); appErr != nil {
return fmt.Sprintf("%s error creating the public post: %s", subscriptionSuccess, appErr.Error())
}

return ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized this is going to be really noisy if the admin subscribes to several projects in succession. I prefer having those as ephemeral instead of public, but that is just my own preference.

Is it part of this ticket to make this message public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hanzei Please refer to this discussion #513 (comment)

server/plugin/command.go Outdated Show resolved Hide resolved
@hanzei hanzei removed the 2: Dev Review Requires review by a core committer label Mar 30, 2023
@Kshitij-Katiyar
Copy link
Contributor Author

Heads up that there are conflicts to resolve.

@hanzei Fixed the merged conflicts

@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 Jul 6, 2023

@Kshitij-Katiyar Would you please merge master?

@Kshitij-Katiyar
Copy link
Contributor Author

@Kshitij-Katiyar Would you please merge master?

@hanzei synced with master

Copy link

@AayushChaudhary0001 AayushChaudhary0001 left a comment

Choose a reason for hiding this comment

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

Tested and Approved.
Subscriptions message is reflected fine for new subscriptions. Also, events and usernames are also reflected in the subscription message.
Working fine, LGTM.

@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Nov 27, 2023
@hanzei
Copy link
Contributor

hanzei commented Nov 27, 2023

@Kshitij-Katiyar Would you please resolve the conflicts?

@avas27JTG
Copy link
Contributor

@Kshitij-Katiyar Would you please resolve the conflicts?

@hanzei I've done it.

@hanzei hanzei merged commit 8cf783f into mattermost:master Nov 28, 2023
9 checks passed
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
8 participants