Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fix webtools blacklist APIs [#62](https://github.com/rokwire/gateway-building-block/issues/62)

[2.4.0] - 2024-03-29
### Added
- Ability to block/blacklist specific Webtools events [#57](https://github.com/rokwire/gateway-building-block/issues/57)
Expand Down
40 changes: 22 additions & 18 deletions driven/storage/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,28 +401,32 @@ func (a *Adapter) AddWebtoolsBlacklistData(dataSourceIDs []string, dataCalendarI

// RemoveWebtoolsBlacklistData update data from the database
func (a *Adapter) RemoveWebtoolsBlacklistData(dataSourceIDs []string, dataCalendarIDs []string) error {
filterSource := bson.M{"name": "webtools_events_ids"}
updateSource := bson.M{
"$pull": bson.M{
"data": bson.M{"$in": dataSourceIDs},
},
}
if dataSourceIDs != nil {
filterSource := bson.M{"name": "webtools_events_ids"}
updateSource := bson.M{
"$pull": bson.M{
"data": bson.M{"$in": dataSourceIDs},
},
}

_, err := a.db.webtoolsBlacklistItems.UpdateOne(a.context, filterSource, updateSource, nil)
if err != nil {
return errors.WrapErrorAction(logutils.ActionUpdate, model.TypeExample, filterArgs(filterSource), err)
_, err := a.db.webtoolsBlacklistItems.UpdateOne(a.context, filterSource, updateSource, nil)
if err != nil {
return errors.WrapErrorAction(logutils.ActionUpdate, model.TypeExample, filterArgs(filterSource), err)
}
}
if dataCalendarIDs != nil {
filterCalendar := bson.M{"name": "webtools_calendar_ids"}
updateCalendar := bson.M{
"$pull": bson.M{
"data": bson.M{"$in": dataCalendarIDs},
},
}

filterCalendar := bson.M{"name": "webtools_calendar_ids"}
updateCalendar := bson.M{
"$pull": bson.M{
"data": bson.M{"$in": dataCalendarIDs},
},
}
_, err := a.db.webtoolsBlacklistItems.UpdateOne(a.context, filterCalendar, updateCalendar, nil)
if err != nil {
return errors.WrapErrorAction(logutils.ActionUpdate, model.TypeExample, filterArgs(filterCalendar), err)
}

_, err = a.db.webtoolsBlacklistItems.UpdateOne(a.context, filterCalendar, updateCalendar, nil)
if err != nil {
return errors.WrapErrorAction(logutils.ActionUpdate, model.TypeExample, filterArgs(filterCalendar), err)
}

return nil
Expand Down
20 changes: 10 additions & 10 deletions driver/web/apis_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,20 @@ func (h AdminAPIsHandler) addwebtoolsblacklist(l *logs.Log, r *http.Request, cla
}

var dataSourceIDs []string
for _, w := range *requestData.DataSourceIds {
if w != "" {
dataSourceIDs = append(dataSourceIDs, w)
} else {
dataSourceIDs = nil
if requestData.DataSourceIds != nil {
for _, w := range *requestData.DataSourceIds {
if w != "" {
dataSourceIDs = append(dataSourceIDs, w)
}
}
}

var dataCalendarIDs []string
for _, w := range *requestData.DataCalendarIds {
if w != "" {
dataCalendarIDs = append(dataCalendarIDs, w)
} else {
dataCalendarIDs = nil
if requestData.DataCalendarIds != nil {
for _, w := range *requestData.DataCalendarIds {
if w != "" {
dataCalendarIDs = append(dataCalendarIDs, w)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions driver/web/docs/gen/def.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,12 @@ paths:
properties:
data_source_ids:
type: array
nullable: true
items:
type: string
data_calendar_ids:
type: array
nullable: true
items:
type: string
responses:
Expand Down
4 changes: 2 additions & 2 deletions driver/web/docs/gen/gen_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ type: object
properties:
data_source_ids:
type: array
nullable: true
items:
type: string
data_calendar_ids:
type: array
nullable: true
items:
type: string