From b35f7f6a3d7b2bb3e817b8887168d204bee93520 Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Thu, 14 Sep 2023 16:55:29 +0530 Subject: [PATCH 1/2] [MI-3515] Display proper message for access request todo --- server/plugin.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/plugin.go b/server/plugin.go index ab1790a6f..01429b445 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -46,8 +46,8 @@ const ( SettingReminders = "reminders" SettingOn = "on" SettingOff = "off" - - chimeraGitLabAppIdentifier = "plugin-gitlab" + ActionNameMemberAccessRequest = "member_access_requested" + chimeraGitLabAppIdentifier = "plugin-gitlab" invalidTokenError = "401 {error: invalid_token}" //#nosec G101 -- False positive ) @@ -606,7 +606,12 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri continue } notificationCount++ - notificationContent += fmt.Sprintf("* %v : [%v](%v)\n", n.ActionName, n.Target.Title, n.TargetURL) + + if n.ActionName == ActionNameMemberAccessRequest { + notificationContent += fmt.Sprintf("* %v : [%v](%v) has requested access to [%v](%v)\n", n.ActionName, n.Author.Name, n.Author.WebURL, n.Body, n.TargetURL) + } else { + notificationContent += fmt.Sprintf("* %v : [%v](%v)\n", n.ActionName, n.Target.Title, n.TargetURL) + } } if notificationCount == 0 { From 92fca6fba9ec2dc5c90b7f95336fbe88f3ced5b5 Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Thu, 21 Sep 2023 17:55:32 +0530 Subject: [PATCH 2/2] [MI-3515] Review fix --- server/plugin.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/plugin.go b/server/plugin.go index 01429b445..140741d48 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -46,9 +46,10 @@ const ( SettingReminders = "reminders" SettingOn = "on" SettingOff = "off" - ActionNameMemberAccessRequest = "member_access_requested" chimeraGitLabAppIdentifier = "plugin-gitlab" + ActionNameMemberAccessRequest = "member_access_requested" + invalidTokenError = "401 {error: invalid_token}" //#nosec G101 -- False positive ) @@ -607,9 +608,11 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri } notificationCount++ - if n.ActionName == ActionNameMemberAccessRequest { + switch n.ActionName { + // Handling this cases specifically as the "Title" field is empty in this case + case ActionNameMemberAccessRequest: notificationContent += fmt.Sprintf("* %v : [%v](%v) has requested access to [%v](%v)\n", n.ActionName, n.Author.Name, n.Author.WebURL, n.Body, n.TargetURL) - } else { + default: notificationContent += fmt.Sprintf("* %v : [%v](%v)\n", n.ActionName, n.Target.Title, n.TargetURL) } }