Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(middleware): get legacy device-info #459

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/notifier/slack_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
SlackNotifier,
)

token = os.getenv("SLACK_API_TOKEN")
token = os.getenv("SLACK_TOKEN")

if not token:
raise ValueError("Please, configure the SLACK_API_TOKEN envvar")
raise ValueError("Please, configure the SLACK_TOKEN envvar")

gke_accessory = {
"type": "button",
Expand All @@ -24,7 +24,7 @@
}
notifier = SlackNotifier(
token=token,
channel="warnings-staging",
channel="testing",
converter=BlocksSlackNotifierMessageConverter(slack_accessory=gke_accessory),
exception_converter=ExceptionBlocksSlackNotifierMessageConverter(
slack_accessory=gke_accessory,
Expand Down
9 changes: 8 additions & 1 deletion petisco/base/application/middleware/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ def get_meta_from_input(self) -> Dict[str, Any]:
try:
info_id = self.wrapped_class_input_arguments.get("info_id")
if info_id and hasattr(info_id, "to_meta"):
meta = info_id.to_meta().get("info_id", {})
meta.update(info_id.to_meta().get("info_id", {}))
except Exception as exc:
logger.error(f"Middleware error getting info_id on get_meta_from_input: {str(exc)}")

try:
device_info = self.wrapped_class_input_arguments.get("device_info")
if device_info and hasattr(device_info, "to_meta"):
meta.update(device_info.to_meta(metadata_format="new"))
except Exception as exc:
logger.error(f"Middleware error getting device_info on get_meta_from_input: {str(exc)}")

return meta
Loading