lightest + clearest code

This commit is contained in:
mr
2024-11-28 16:49:41 +01:00
parent 8a11805fe8
commit 8d701e67d8
34 changed files with 444 additions and 1448 deletions

View File

@@ -20,7 +20,7 @@ func New(t tools.DataType, peerID string, groups []string, caller *tools.HTTPCal
Caller: caller,
PeerID: peerID,
Groups: groups, // Set the caller
Type: t.String(),
Type: t,
},
}
}
@@ -47,7 +47,7 @@ func (wfa *ruleMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int,
// LoadOne loads a rule from the database
func (wfa *ruleMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var rule Rule
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType().String())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err
@@ -59,7 +59,7 @@ func (wfa *ruleMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
// LoadAll loads all rules from the database
func (wfa ruleMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType().String())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve any from db. Error: " + err.Error())
return nil, code, err
@@ -84,7 +84,7 @@ func (wfa *ruleMongoAccessor) Search(filters *dbs.Filters, search string) ([]uti
},
}
}
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType())
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String())
if err != nil {
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
return nil, code, err