Skip to content

Commit 8b9f6d0

Browse files
committed
fix in DTO
1 parent 7737030 commit 8b9f6d0

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

client/events/EventClient.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,34 @@ func (impl *EventRESTClientImpl) sendEvent(event Event) (bool, error) {
287287
return false, err
288288
}
289289

290+
// convert notificationSetting to notificationSettingbean
291+
notificationSettingsBean := make([]*repository.NotificationSettingsBean, 0)
292+
for _, item := range notificationSettings {
293+
config := make([]repository.ConfigEntry, 0)
294+
if item.Config != "" {
295+
err := json.Unmarshal([]byte(item.Config), &config)
296+
if err != nil {
297+
impl.logger.Errorw("error while unmarshaling config", "err", err)
298+
return false, err
299+
}
300+
}
301+
notificationSettingsBean = append(notificationSettingsBean, &repository.NotificationSettingsBean{
302+
Id: item.Id,
303+
TeamId: item.TeamId,
304+
AppId: item.AppId,
305+
EnvId: item.EnvId,
306+
PipelineId: item.PipelineId,
307+
PipelineType: item.PipelineType,
308+
EventTypeId: item.EventTypeId,
309+
Config: config,
310+
ViewId: item.ViewId,
311+
})
312+
}
313+
290314
// Create a combined payload with event and notification settings
291315
combinedPayload := map[string]interface{}{
292316
"event": event,
293-
"notificationSettings": notificationSettings,
317+
"notificationSettings": notificationSettingsBean,
294318
}
295319

296320
// Marshal the combined payload

internal/sql/repository/NotificationSettingsRepository.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ type NotificationSettings struct {
9090
ClusterId *int `sql:"cluster_id"`
9191
}
9292

93+
type NotificationSettingsBean struct {
94+
Id int `json:"id"`
95+
TeamId *int `json:"team_id"`
96+
AppId *int `json:"app_id"`
97+
EnvId *int `json:"env_id"`
98+
PipelineId *int `json:"pipeline_id"`
99+
PipelineType string `json:"pipeline_type"`
100+
EventTypeId int `json:"event_type_id"`
101+
Config []ConfigEntry `json:"config"`
102+
ViewId int `json:"view_id"`
103+
}
104+
105+
type ConfigEntry struct {
106+
Dest string `json:"dest"`
107+
Rule string `json:"rule"`
108+
ConfigId int `json:"configId"`
109+
Recipient string `json:"recipient"`
110+
}
111+
93112
type SettingOptionDTO struct {
94113
//TeamId int `json:"-"`
95114
//AppId int `json:"-"`

0 commit comments

Comments
 (0)