diff --git a/lib/aprsme/broadcast_task_supervisor.ex b/lib/aprsme/broadcast_task_supervisor.ex index 09a4283..0f0f9f2 100644 --- a/lib/aprsme/broadcast_task_supervisor.ex +++ b/lib/aprsme/broadcast_task_supervisor.ex @@ -51,9 +51,7 @@ defmodule Aprsme.BroadcastTaskSupervisor do # Process in chunks to balance load |> Stream.chunk_every(10) |> Enum.each(fn topic_chunk -> - Enum.each(topic_chunk, fn topic -> - Phoenix.PubSub.broadcast(pubsub, topic, message) - end) + broadcast_to_topics(topic_chunk, message, pubsub) end) end) @@ -102,4 +100,11 @@ defmodule Aprsme.BroadcastTaskSupervisor do rescue _ -> 0.0 end + + # Private helper to broadcast to multiple topics + defp broadcast_to_topics(topics, message, pubsub) do + Enum.each(topics, fn topic -> + Phoenix.PubSub.broadcast(pubsub, topic, message) + end) + end end diff --git a/lib/aprsme/log_sanitizer.ex b/lib/aprsme/log_sanitizer.ex index acef9f3..113b78a 100644 --- a/lib/aprsme/log_sanitizer.ex +++ b/lib/aprsme/log_sanitizer.ex @@ -43,17 +43,20 @@ defmodule Aprsme.LogSanitizer do def sanitize_map(data), do: data + # Helper to redact a matched sensitive pattern + defp redact_match(match) do + case String.split(match, ["=", ":"]) do + [key, _value] -> "#{key}=[REDACTED]" + _ -> "[REDACTED]" + end + end + @doc """ Sanitize a string by replacing sensitive patterns """ def sanitize_string(data) when is_binary(data) do Enum.reduce(@sensitive_patterns, data, fn pattern, acc -> - Regex.replace(pattern, acc, fn match -> - case String.split(match, ["=", ":"]) do - [key, _value] -> "#{key}=[REDACTED]" - _ -> "[REDACTED]" - end - end) + Regex.replace(pattern, acc, &redact_match/1) end) end