AY-5539 - fix wrong logic

This commit is contained in:
Petr Kalis 2024-06-03 12:06:29 +02:00
parent c7f0e977f7
commit 4e07b756af

View file

@ -1841,7 +1841,7 @@ class PublisherController(BasePublisherController):
allowed_creator_labels = self._get_allowed_creator_labels()
for identifier, creator in self._create_context.creators.items():
try:
if (not self._label_matches_allowed(
if (not self._is_label_allowed(
creator.label, allowed_creator_labels)):
self.log.debug(f"{creator.label} not allowed for context")
continue
@ -1888,13 +1888,12 @@ class PublisherController(BasePublisherController):
self.log.debug(f"Only allowed `{allowed_creator_labels}` creators")
return allowed_creator_labels
def _label_matches_allowed(self, label, allowed_labels):
def _is_label_allowed(self, label, allowed_labels):
"""Implement regex support for allowed labels."""
if allowed_labels:
allowed_patterns = re.compile("|".join(allowed_labels))
if allowed_patterns.match(label):
return True
return False
if not allowed_labels:
return True
allowed_patterns = re.compile("|".join(allowed_labels))
return bool(allowed_patterns.match(label))
def _reset_instances(self):
"""Reset create instances."""