Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ianperera committed Feb 21, 2025
1 parent 60676c2 commit 92d07a8
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions modules/va_notify/lib/va_notify/default_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,18 @@ def call

private

# rubocop:disable Metrics/MethodLength
def call_with_metadata
notification_type = metadata['notification_type']

tags = begin
if Flipper.enabled?(:va_notify_metadata_statsd_tags)
validate_and_normalize_statsd_tags
else
statsd_tags = metadata['statsd_tags']
service = statsd_tags['service']
function = statsd_tags['function']
["service:#{service}", "function:#{function}"]
end
rescue TypeError, KeyError => e
Rails.logger.error(
"VANotify: Invalid metadata format: #{e.message}",
notification_record_id: notification_record.id
)
# Invalid metadata is treated as if no metadata were provided.
return call_without_metadata
end
tags = if Flipper.enabled?(:va_notify_metadata_statsd_tags)
validate_and_normalize_statsd_tags
else
statsd_tags = metadata['statsd_tags']
service = statsd_tags['service']
function = statsd_tags['function']
["service:#{service}", "function:#{function}"]
end

case notification_record.status
when 'delivered'
Expand All @@ -47,7 +39,15 @@ def call_with_metadata
# 'temporary-failure' is an end state for the notification; VANotify API does not auto-retry these.
permanent_failure(tags) if notification_type == 'error'
end
rescue TypeError, KeyError => e
Rails.logger.error(
"VANotify: Invalid metadata format: #{e.message}",
notification_record_id: notification_record.id
)
# Invalid metadata is treated as if no metadata were provided.
call_without_metadata
end
# rubocop:enable Metrics/MethodLength

def call_without_metadata
case notification_record.status
Expand Down

0 comments on commit 92d07a8

Please sign in to comment.