Skip to content

Commit 4aa4f2c

Browse files
committed
removed deprecated api
1 parent 05507be commit 4aa4f2c

File tree

2 files changed

+0
-65
lines changed

2 files changed

+0
-65
lines changed

api/restHandler/NotificationRestHandler.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ const (
5151
)
5252

5353
type NotificationRestHandler interface {
54-
SaveNotificationSettings(w http.ResponseWriter, r *http.Request)
5554
SaveNotificationSettingsV2(w http.ResponseWriter, r *http.Request)
5655
UpdateNotificationSettings(w http.ResponseWriter, r *http.Request)
5756
SaveNotificationChannelConfig(w http.ResponseWriter, r *http.Request)
@@ -118,66 +117,6 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry
118117
}
119118
}
120119

121-
// SaveNotificationSettings will be deprecated in future
122-
func (impl NotificationRestHandlerImpl) SaveNotificationSettings(w http.ResponseWriter, r *http.Request) {
123-
userId, err := impl.userAuthService.GetLoggedInUser(r)
124-
if userId == 0 || err != nil {
125-
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
126-
return
127-
}
128-
var notificationSetting beans.NotificationRequest
129-
err = json.NewDecoder(r.Body).Decode(&notificationSetting)
130-
if err != nil {
131-
impl.logger.Errorw("request err, SaveNotificationSettings", "err", err, "payload", notificationSetting)
132-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
133-
return
134-
}
135-
impl.logger.Infow("request payload, SaveNotificationSettings", "err", err, "payload", notificationSetting)
136-
err = impl.validator.Struct(notificationSetting)
137-
if err != nil {
138-
impl.logger.Errorw("validation err, SaveNotificationSettings", "err", err, "payload", notificationSetting)
139-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
140-
return
141-
}
142-
143-
//RBAC
144-
token := r.Header.Get("token")
145-
if isSuperAdmin := impl.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !isSuperAdmin {
146-
common.WriteJsonResp(w, err, nil, http.StatusForbidden)
147-
return
148-
}
149-
//RBAC
150-
151-
providers := notificationSetting.Providers
152-
153-
if len(providers) != 0 {
154-
for _, provider := range providers {
155-
if provider.Destination == util.SMTP || provider.Destination == util.SES {
156-
if provider.Recipient == "" {
157-
userEmail, err := impl.userAuthService.GetEmailById(int32(provider.ConfigId))
158-
if err != nil {
159-
impl.logger.Errorw("service err, SaveNotificationSettings", "err", err, "payload", notificationSetting)
160-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
161-
return
162-
}
163-
provider.Recipient = userEmail
164-
}
165-
// get default configID for SES and SMTP
166-
provider.ConfigId = notificationSetting.SesConfigId
167-
}
168-
}
169-
}
170-
171-
res, err := impl.notificationService.CreateOrUpdateNotificationSettings(&notificationSetting, userId)
172-
if err != nil {
173-
impl.logger.Errorw("service err, SaveNotificationSettings", "err", err, "payload", notificationSetting)
174-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
175-
return
176-
}
177-
w.Header().Set("Content-Type", "application/json")
178-
common.WriteJsonResp(w, nil, res, http.StatusOK)
179-
}
180-
181120
func (impl NotificationRestHandlerImpl) SaveNotificationSettingsV2(w http.ResponseWriter, r *http.Request) {
182121
userId, err := impl.userAuthService.GetLoggedInUser(r)
183122
if userId == 0 || err != nil {

api/router/NotificationRouter.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ func NewNotificationRouterImpl(notificationRestHandler restHandler.NotificationR
3232
return &NotificationRouterImpl{notificationRestHandler: notificationRestHandler}
3333
}
3434
func (impl NotificationRouterImpl) InitNotificationRegRouter(configRouter *mux.Router) {
35-
// to maintain backward compatibility, will be deprecated in future
36-
configRouter.Path("").
37-
HandlerFunc(impl.notificationRestHandler.SaveNotificationSettings).
38-
Methods("POST")
3935
// new router to save notification settings
4036
configRouter.Path("/v2").
4137
HandlerFunc(impl.notificationRestHandler.SaveNotificationSettingsV2).

0 commit comments

Comments
 (0)