From 548dd79742044efabcfe506fa33fa07db1d765ac Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 15 Oct 2021 09:58:48 +0300 Subject: [PATCH] Add opts for sessions (continued) --- config/config_defaults.go | 28 ++++++++++++++++++++++++++++ sessions/sessions.go | 25 +++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/config/config_defaults.go b/config/config_defaults.go index 4f27f83b4..a6618d493 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -647,6 +647,34 @@ const CGRATES_CFG_JSON = ` // "Value": false, // }, ], + "*initiate": [ + // { + // "Tenant": "*any", + // "FilterIDs": [], + // "Value": false, + // }, + ], + "*update": [ + // { + // "Tenant": "*any", + // "FilterIDs": [], + // "Value": false, + // }, + ], + "*terminate": [ + // { + // "Tenant": "*any", + // "FilterIDs": [], + // "Value": false, + // }, + ], + "*message": [ + // { + // "Tenant": "*any", + // "FilterIDs": [], + // "Value": false, + // }, + ], }, }, diff --git a/sessions/sessions.go b/sessions/sessions.go index 9bdc4ed6f..83a670b0b 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1804,7 +1804,11 @@ func (sS *SessionS) BiRPCv1InitiateSession(ctx *context.Context, config.SessionsAttributesDftOpt, utils.OptsAttributeS); err != nil { return } - initS := utils.OptAsBool(args.APIOpts, utils.OptsSesInitiate) + var initS bool + if initS, err = engine.GetBoolOpts(ctx, args.Tenant, args, sS.filterS, sS.cgrCfg.SessionSCfg().Opts.Initiate, + config.SessionsInitiateDftOpt, utils.OptsSesInitiate); err != nil { + return + } resS := utils.OptAsBool(args.APIOpts, utils.OptsSesResourceSAlocate) if !(attrS || initS || resS) { return // nothing to do @@ -1984,7 +1988,11 @@ func (sS *SessionS) BiRPCv1UpdateSession(ctx *context.Context, config.SessionsAttributesDftOpt, utils.OptsAttributeS); err != nil { return } - updS := utils.OptAsBool(args.APIOpts, utils.OptsSesUpdate) + var updS bool + if updS, err = engine.GetBoolOpts(ctx, args.Tenant, args, sS.filterS, sS.cgrCfg.SessionSCfg().Opts.Update, + config.SessionsUpdateDftOpt, utils.OptsSesUpdate); err != nil { + return + } if !(attrS || updS) { return // nothing to do } @@ -2071,7 +2079,11 @@ func (sS *SessionS) BiRPCv1TerminateSession(ctx *context.Context, } // end of RPC caching resS := utils.OptAsBool(args.APIOpts, utils.OptsSesResourceSRelease) - termS := utils.OptAsBool(args.APIOpts, utils.OptsSesTerminate) + var termS bool + if termS, err = engine.GetBoolOpts(ctx, args.Tenant, args, sS.filterS, sS.cgrCfg.SessionSCfg().Opts.Terminate, + config.SessionsTerminateDftOpt, utils.OptsSesTerminate); err != nil { + return + } if !(resS || termS) { return // nothing to do } @@ -2305,7 +2317,12 @@ func (sS *SessionS) BiRPCv1ProcessMessage(ctx *context.Context, rply.RouteProfiles = routesReply } } - if utils.OptAsBool(args.APIOpts, utils.OptsSesMessage) { + var message bool + if message, err = engine.GetBoolOpts(ctx, args.Tenant, args, sS.filterS, sS.cgrCfg.SessionSCfg().Opts.Message, + config.SessionsMessageDftOpt, utils.OptsSesMessage); err != nil { + return + } + if message { var maxUsage time.Duration if maxUsage, err = sS.chargeEvent(ctx, args, utils.OptAsBool(args.APIOpts, utils.OptsSesForceDuration)); err != nil { return err