events: disable policy cache for trigger
This commit is contained in:
parent
6192b2787f
commit
eef111bcfd
|
@ -36,23 +36,26 @@ def event_trigger_handler(event_uuid: str, trigger_name: str):
|
||||||
if trigger.policies.filter(policy_uuid=policy_uuid).exists():
|
if trigger.policies.filter(policy_uuid=policy_uuid).exists():
|
||||||
# Event has been created by a policy that is attached
|
# Event has been created by a policy that is attached
|
||||||
# to this trigger. To prevent infinite loops, we stop here
|
# to this trigger. To prevent infinite loops, we stop here
|
||||||
LOGGER.debug("e(trigger): attempting to prevent infinite loop")
|
LOGGER.debug(
|
||||||
|
"e(trigger): attempting to prevent infinite loop", trigger=trigger
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not trigger.group:
|
if not trigger.group:
|
||||||
LOGGER.debug("e(trigger): trigger has no group")
|
LOGGER.debug("e(trigger): trigger has no group", trigger=trigger)
|
||||||
return
|
return
|
||||||
|
|
||||||
policy_engine = PolicyEngine(trigger, get_anonymous_user())
|
policy_engine = PolicyEngine(trigger, get_anonymous_user())
|
||||||
policy_engine.mode = PolicyEngineMode.MODE_OR
|
policy_engine.mode = PolicyEngineMode.MODE_OR
|
||||||
policy_engine.empty_result = False
|
policy_engine.empty_result = False
|
||||||
|
policy_engine.use_cache = False
|
||||||
policy_engine.request.context["event"] = event
|
policy_engine.request.context["event"] = event
|
||||||
policy_engine.build()
|
policy_engine.build()
|
||||||
result = policy_engine.result
|
result = policy_engine.result
|
||||||
if not result.passing:
|
if not result.passing:
|
||||||
return
|
return
|
||||||
|
|
||||||
LOGGER.debug("e(trigger): event trigger matched")
|
LOGGER.debug("e(trigger): event trigger matched", trigger=trigger)
|
||||||
# Create the notification objects
|
# Create the notification objects
|
||||||
for user in trigger.group.users.all():
|
for user in trigger.group.users.all():
|
||||||
notification = Notification.objects.create(
|
notification = Notification.objects.create(
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import { EventContext } from "./Events";
|
||||||
|
|
||||||
export class Group {
|
export class Group {
|
||||||
|
|
||||||
group_uuid: string;
|
group_uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
is_superuser: boolean;
|
is_superuser: boolean;
|
||||||
attributes: object;
|
attributes: EventContext;
|
||||||
parent?: Group;
|
parent?: Group;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
Reference in New Issue