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

[MI-2820]: Modified API endpoint to require a project to be provided #144

Merged
merged 185 commits into from
Mar 29, 2023

Conversation

avas27JTG
Copy link
Contributor

Modified API endpoint to require a project to be provided

raghavaggarwal2308 and others added 30 commits November 1, 2022 14:11
1. Updated API to support creating pipeline subscriptions.
2. Updated the UI for subscription modal to display pipeline event types.
3. Updated the UI of subscription card for for displaying pipeline subscriptions.
…eployment started" and "Release deployment completed"
…pipeline job request from requested user via MM post.
avas27JTG and others added 9 commits February 7, 2023 12:27
…e central login into it, formatted code (#32)

* [MI-2669]: Created a hook for intercepting redux changes and moved the central login into it, formatted code

* [MI-2669]: Modified comment

* [MI-2669]: Review fixes

---------

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…ser for oAuth. (#35)

* [MI-2748]: Implemented 1:1 mapping between MM user and Azure DevOps user for oAuth.

* [MI-2748]: Added 1 test case and http response code

* [MI-2748]: Fixed condition

* [MI-2748]: Fixed token refresh logic

* [MI-2748]: Fixed CI

* [MI-2748]: Fixed CI

* [MI-2748]: Review fixes

* [MI-2748]: Fixed CI

* [MI-2748]: Review fixes

* [MI-2748]: Review fixes

---------

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…om plugin's server. (#36)

* [MI-2750]: Implemented fetching channel list on webapp and remove from plugin's server.

* [MI-2750]: Review fixes

* [MI-2750]: Changed comment message

---------

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…er (#37)

* [MI-2765]: Used @mattermost/client for making webapp calls to MM server

* [MI-2765]: Review fix

* [MI-2765]: Review fix

* [MI-2765]: Removed Mattermost API call RTK service

* [MI-2765]: Fixed CI

---------

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>

organization := pathParams[constants.PathParamOrganization]
project := pathParams[constants.PathParamProject]
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: strings.ToLower(organization), ProjectName: cases.Title(language.Und).String(project)}); !isProjectLinked {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot going on in this line. Maybe break this into local variables first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

organization := pathParams[constants.PathParamOrganization]
project := pathParams[constants.PathParamProject]
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: strings.ToLower(organization), ProjectName: cases.Title(language.Und).String(project)}); !isProjectLinked {
p.API.LogError(fmt.Sprintf("Project %s is not linked", project))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use LogWarn since there isn't an actionable step for the admin to fix this. Please keep this is mind for other features/fixes implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, fixed

}

organization := pathParams[constants.PathParamOrganization]
project := pathParams[constants.PathParamProject]
Copy link
Contributor

Choose a reason for hiding this comment

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

We could "return early" if project is blank right? Before we interact with the store

Copy link
Contributor Author

@avas27JTG avas27JTG Feb 27, 2023

Choose a reason for hiding this comment

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

We have made organization and project as path params here so, if they are empty this API will not be called and we will not reach here and get 404

@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Feb 26, 2023
@hanzei hanzei changed the base branch from epic_phase_3 to master February 26, 2023 21:58
@hanzei hanzei changed the base branch from master to epic_phase_3 February 26, 2023 21:59
@hanzei
Copy link
Contributor

hanzei commented Feb 26, 2023

@avas27JTG Could you please rebase against master and change the target branch?

@avas27JTG avas27JTG changed the base branch from epic_phase_3 to master February 27, 2023 08:06
@avas27JTG avas27JTG requested a review from mickmister February 27, 2023 08:10
@@ -413,6 +413,26 @@ func (p *Plugin) handleGetSubscriptions(w http.ResponseWriter, r *http.Request)
return
}

projectList, err := p.Store.GetAllProjects(mattermostUserID)
if err != nil {
p.API.LogError(constants.ErrorFetchProjectList, "Error", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about using LogWarn instead here

@@ -432,7 +452,6 @@ func (p *Plugin) handleGetSubscriptions(w http.ResponseWriter, r *http.Request)
channelID := r.URL.Query().Get(constants.QueryParamChannelID)
serviceType := r.URL.Query().Get(constants.QueryParamServiceType)
eventType := r.URL.Query().Get(constants.QueryParamEventType)
project := r.URL.Query().Get(constants.QueryParamProject)
if project != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the intended functionality when project is an empty string? The code reads a bit weird because there is a large block for handling when it's not empty, but then the function ends after that block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code will reach here only when the project is not empty and it's valid i.e. linked/exists on the plugin
and in that case, we are returning the array of subscriptions

Removed this check as it's no longer needed now as we have made it required now

@avas27JTG avas27JTG requested a review from mickmister February 28, 2023 15:52
@hanzei hanzei requested a review from m1lt0n March 28, 2023 19:00
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Mar 29, 2023
@hanzei hanzei merged commit 4f8e0b0 into master Mar 29, 2023
@hanzei hanzei deleted the MI-2820 branch March 29, 2023 11:15
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants