From f1f6ed115472c0fb7a7dbccd6a89b034cd77f044 Mon Sep 17 00:00:00 2001 From: ayusht2810 Date: Fri, 26 Apr 2024 14:14:21 +0530 Subject: [PATCH 1/4] Update subscription messages with respect to webhook --- server/plugin/command.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/plugin/command.go b/server/plugin/command.go index 7fb317c0a..54f85b6ea 100644 --- a/server/plugin/command.go +++ b/server/plugin/command.go @@ -366,8 +366,7 @@ func (p *Plugin) checkIfConfiguredWebhookExists(ctx context.Context, githubClien } func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, parameters []string, userInfo *GitHubUserInfo) string { - const errorNoWebhookFound = "\nNo webhook was found for this repository or organization. To create one, enter the following slash command `/github setup webhook`" - const errorWebhookToUser = "\nNot able to get the list of webhooks. This feature is not available for subscription to a user." + const errorNoWebhookFound = "\n**Note:** No webhook was found for this repository or organization. To create one, enter the following slash command `/github setup webhook`" subscriptionEvents := Features("pulls,issues,creates,deletes") if len(parameters) == 0 { return "Please specify a repository." @@ -459,7 +458,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, foundErr := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if foundErr != nil { if strings.Contains(foundErr.Error(), "404 Not Found") { - return errorWebhookToUser + return subOrgMsg } return errors.Wrap(foundErr, "failed to get the list of webhooks").Error() } @@ -498,7 +497,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, err := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if err != nil { if strings.Contains(err.Error(), "404 Not Found") { - return errorWebhookToUser + return msg } return errors.Wrap(err, "failed to get the list of webhooks").Error() } From 8fd6ef7ebfc23ac77a38ec16b864db90b37fb464 Mon Sep 17 00:00:00 2001 From: ayusht2810 Date: Tue, 30 Apr 2024 16:04:45 +0530 Subject: [PATCH 2/4] Add comment --- server/plugin/command.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/plugin/command.go b/server/plugin/command.go index 54f85b6ea..c7604e02a 100644 --- a/server/plugin/command.go +++ b/server/plugin/command.go @@ -458,6 +458,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, foundErr := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if foundErr != nil { if strings.Contains(foundErr.Error(), "404 Not Found") { + // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorised to access webhooks. return subOrgMsg } return errors.Wrap(foundErr, "failed to get the list of webhooks").Error() @@ -497,6 +498,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, err := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if err != nil { if strings.Contains(err.Error(), "404 Not Found") { + // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorised to access webhooks. return msg } return errors.Wrap(err, "failed to get the list of webhooks").Error() From 734eb1e92aebb012d09840b6f5d1eb7ecf06b345 Mon Sep 17 00:00:00 2001 From: ayusht2810 Date: Tue, 30 Apr 2024 16:07:42 +0530 Subject: [PATCH 3/4] Fix lint error --- server/plugin/command.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/plugin/command.go b/server/plugin/command.go index c7604e02a..ea953830f 100644 --- a/server/plugin/command.go +++ b/server/plugin/command.go @@ -458,7 +458,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, foundErr := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if foundErr != nil { if strings.Contains(foundErr.Error(), "404 Not Found") { - // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorised to access webhooks. + // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorized to access webhooks. return subOrgMsg } return errors.Wrap(foundErr, "failed to get the list of webhooks").Error() @@ -498,7 +498,7 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, found, err := p.checkIfConfiguredWebhookExists(ctx, githubClient, repo, owner) if err != nil { if strings.Contains(err.Error(), "404 Not Found") { - // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorised to access webhooks. + // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorized to access webhooks. return msg } return errors.Wrap(err, "failed to get the list of webhooks").Error() From 34998c68ae396b567cf23fcff94b5407227a0bff Mon Sep 17 00:00:00 2001 From: ayusht2810 Date: Thu, 9 May 2024 17:43:34 +0530 Subject: [PATCH 4/4] Update subscription messages --- server/plugin/command.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/plugin/command.go b/server/plugin/command.go index ea953830f..98580a50f 100644 --- a/server/plugin/command.go +++ b/server/plugin/command.go @@ -459,13 +459,13 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, if foundErr != nil { if strings.Contains(foundErr.Error(), "404 Not Found") { // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorized to access webhooks. - return subOrgMsg + return "" } return errors.Wrap(foundErr, "failed to get the list of webhooks").Error() } if !found { - subOrgMsg += errorNoWebhookFound + subOrgMsg = errorNoWebhookFound } return subOrgMsg } @@ -499,13 +499,13 @@ func (p *Plugin) handleSubscribesAdd(_ *plugin.Context, args *model.CommandArgs, if err != nil { if strings.Contains(err.Error(), "404 Not Found") { // We are not returning an error here and just a subscription success message, as the above error condition occurs when the user is not authorized to access webhooks. - return msg + return "" } return errors.Wrap(err, "failed to get the list of webhooks").Error() } if !found { - msg += errorNoWebhookFound + msg = errorNoWebhookFound } return msg