rename need_body to headersonly

This commit is contained in:
2021-09-09 11:34:47 +02:00
parent be715d8b01
commit 9b30bb68c4
2 changed files with 10 additions and 10 deletions

View File

@@ -255,7 +255,7 @@ class ModifyMilter(Milter.Base):
if action.conditions is None or \
action.conditions.match(host=self.IP):
actions.append(action)
if action.need_body():
if not action.headersonly():
self._headersonly = False
if actions:

View File

@@ -370,7 +370,7 @@ class ActionConfig(BaseConfig):
if self["type"] == "add_header":
self["func"] = add_header
self["need_body"] = False
self["headersonly"] = True
if "field" not in cfg and "header" in cfg:
cfg["field"] = cfg["header"]
@@ -379,7 +379,7 @@ class ActionConfig(BaseConfig):
elif self["type"] == "mod_header":
self["func"] = mod_header
self["need_body"] = False
self["headersonly"] = True
if "field" not in cfg and "header" in cfg:
cfg["field"] = cfg["header"]
@@ -400,7 +400,7 @@ class ActionConfig(BaseConfig):
elif self["type"] == "del_header":
self["func"] = del_header
self["need_body"] = False
self["headersonly"] = True
if "field" not in cfg and "header" in cfg:
cfg["field"] = cfg["header"]
@@ -420,7 +420,7 @@ class ActionConfig(BaseConfig):
elif self["type"] == "add_disclaimer":
self["func"] = add_disclaimer
self["need_body"] = True
self["headersonly"] = False
if "html_template" not in cfg and "html_file" in cfg:
cfg["html_template"] = cfg["html_file"]
@@ -461,12 +461,12 @@ class ActionConfig(BaseConfig):
elif self["type"] == "rewrite_links":
self["func"] = rewrite_links
self["need_body"] = True
self["headersonly"] = False
self.add_string_arg(cfg, "repl")
elif self["type"] == "store":
self["func"] = store
self["need_body"] = True
self["headersonly"] = False
assert "storage_type" in cfg, \
f"{self['name']}: mandatory parameter 'storage_type' not found"
@@ -514,11 +514,11 @@ class Action:
self._name = cfg["name"]
self._func = cfg["func"]
self._args = cfg["args"]
self._need_body = cfg["need_body"]
self._headersonly = cfg["headersonly"]
def need_body(self):
def headersonly(self):
"""Return the needs of this action."""
return self._need_body
return self._headersonly
def execute(self, milter):
"""Execute configured action."""