@@ -371,28 +371,32 @@ func (a *Adapter) FindAllLegacyEvents() ([]model.LegacyEvent, error) {
371
371
372
372
// AddWebtoolsBlacklistData update data from the database
373
373
func (a * Adapter ) AddWebtoolsBlacklistData (dataSourceIDs []string , dataCalendarIDs []string ) error {
374
- filterSource := bson.M {"name" : "webtools_events_ids" }
375
- updateSource := bson.M {
376
- "$addToSet" : bson.M {
377
- "data" : bson.M {"$each" : dataSourceIDs },
378
- },
379
- }
374
+ if dataSourceIDs != nil {
375
+ filterSource := bson.M {"name" : "webtools_events_ids" }
376
+ updateSource := bson.M {
377
+ "$addToSet" : bson.M {
378
+ "data" : bson.M {"$each" : dataSourceIDs },
379
+ },
380
+ }
380
381
381
- _ , err := a .db .webtoolsBlacklistItems .UpdateOne (a .context , filterSource , updateSource , nil )
382
- if err != nil {
383
- return errors .WrapErrorAction (logutils .ActionUpdate , model .TypeExample , filterArgs (filterSource ), err )
382
+ _ , err := a .db .webtoolsBlacklistItems .UpdateOne (a .context , filterSource , updateSource , nil )
383
+ if err != nil {
384
+ return errors .WrapErrorAction (logutils .ActionUpdate , "" , filterArgs (filterSource ), err )
385
+ }
384
386
}
387
+ if dataCalendarIDs != nil {
388
+ filterCalendar := bson.M {"name" : "webtools_calendar_ids" }
389
+ updateCalendar := bson.M {
390
+ "$addToSet" : bson.M {
391
+ "data" : bson.M {"$each" : dataCalendarIDs },
392
+ },
393
+ }
385
394
386
- filterCalendar := bson.M {"name" : "webtools_calendar_ids" }
387
- updateCalendar := bson.M {
388
- "$addToSet" : bson.M {
389
- "data" : bson.M {"$each" : dataCalendarIDs },
390
- },
391
- }
395
+ _ , err := a .db .webtoolsBlacklistItems .UpdateOne (a .context , filterCalendar , updateCalendar , nil )
396
+ if err != nil {
397
+ return errors .WrapErrorAction (logutils .ActionUpdate , "" , filterArgs (filterCalendar ), err )
398
+ }
392
399
393
- _ , err = a .db .webtoolsBlacklistItems .UpdateOne (a .context , filterCalendar , updateCalendar , nil )
394
- if err != nil {
395
- return errors .WrapErrorAction (logutils .ActionUpdate , model .TypeExample , filterArgs (filterCalendar ), err )
396
400
}
397
401
398
402
return nil
0 commit comments