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

MM-16611: leverage relative action URLs #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Net Promoter Score",
"description": "This plugin sends Net Promoter Score surveys to gather user feedback on Mattermost.",
"version": "1.0.1",
"min_server_version": "5.12.0",
"min_server_version": "5.14.0",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
Expand Down
3 changes: 0 additions & 3 deletions server/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ func TestSubmitScore(t *testing.T) {

// Disabling diagnostics allows the handler to run, but prevents data from being sent to Segment
api.On("GetConfig").Return(&model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString("https://mattermost.example.com"),
},
LogSettings: model.LogSettings{
EnableDiagnostics: model.NewBool(false),
},
Expand Down
4 changes: 1 addition & 3 deletions server/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,12 @@ func (p *Plugin) buildSurveyPostAction() *model.PostAction {
})
}

siteURL := *p.API.GetConfig().ServiceSettings.SiteURL

return &model.PostAction{
Name: "Select an option...",
Type: model.POST_ACTION_TYPE_SELECT,
Options: options,
Integration: &model.PostActionIntegration{
URL: fmt.Sprintf("%s/plugins/%s/api/v1/score", siteURL, manifest.Id),
URL: fmt.Sprintf("/plugins/%s/api/v1/score", manifest.Id),
},
}
}
Expand Down
4 changes: 0 additions & 4 deletions server/survey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ func TestCheckForSurveyDM(t *testing.T) {
StartAt: now,
}), nil)
api.On("KVGet", fmt.Sprintf(USER_SURVEY_KEY, user.Id)).Return(nil, nil)
api.On("GetConfig").Return(&model.Config{ServiceSettings: model.ServiceSettings{SiteURL: model.NewString("https://mattermost.example.com")}})
api.On("GetDirectChannel", user.Id, botUserID).Return(&model.Channel{}, nil)
api.On("CreatePost", mock.Anything).Return(&model.Post{Id: postID}, nil)
api.On("KVSet", fmt.Sprintf(USER_SURVEY_KEY, user.Id), newSurveyStateBytes).Return(nil)
Expand All @@ -627,7 +626,6 @@ func TestCheckForSurveyDM(t *testing.T) {
StartAt: now,
}), nil)
api.On("KVGet", fmt.Sprintf(USER_SURVEY_KEY, user.Id)).Return(nil, nil)
api.On("GetConfig").Return(&model.Config{ServiceSettings: model.ServiceSettings{SiteURL: model.NewString("https://mattermost.example.com")}})
api.On("GetDirectChannel", user.Id, botUserID).Return(&model.Channel{}, nil)
api.On("CreatePost", mock.Anything).Return(&model.Post{Id: postID}, nil)
api.On("KVSet", fmt.Sprintf(USER_SURVEY_KEY, user.Id), newSurveyStateBytes).Return(&model.AppError{})
Expand All @@ -652,7 +650,6 @@ func TestCheckForSurveyDM(t *testing.T) {
StartAt: now,
}), nil)
api.On("KVGet", fmt.Sprintf(USER_SURVEY_KEY, user.Id)).Return(nil, nil)
api.On("GetConfig").Return(&model.Config{ServiceSettings: model.ServiceSettings{SiteURL: model.NewString("https://mattermost.example.com")}})
api.On("GetDirectChannel", user.Id, botUserID).Return(&model.Channel{}, nil)
api.On("CreatePost", mock.Anything).Return(nil, &model.AppError{})
defer api.AssertExpectations(t)
Expand Down Expand Up @@ -680,7 +677,6 @@ func TestCheckForSurveyDM(t *testing.T) {
SentAt: now.Add(-1 * MIN_TIME_BETWEEN_USER_SURVEYS),
AnsweredAt: now.Add(-1 * MIN_TIME_BETWEEN_USER_SURVEYS),
}), nil)
api.On("GetConfig").Return(&model.Config{ServiceSettings: model.ServiceSettings{SiteURL: model.NewString("https://mattermost.example.com")}})
api.On("GetDirectChannel", user.Id, botUserID).Return(&model.Channel{}, nil)
api.On("CreatePost", mock.Anything).Return(&model.Post{Id: postID}, nil)
api.On("KVSet", fmt.Sprintf(USER_SURVEY_KEY, user.Id), newSurveyStateBytes).Return(nil)
Expand Down