Skip to content

Commit

Permalink
style(rubocop): Style/SafeNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Feb 12, 2024
1 parent 04a3483 commit 00a02f2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
8 changes: 3 additions & 5 deletions .rubocop.yml
Expand Up @@ -84,11 +84,6 @@ Style/ConditionalAssignment:
Style/EmptyMethod:
EnforcedStyle: expanded

# We do not wish to auto correct unused method arguments because that can be a
# pain. These should just be flagged for manual intervention.
Lint/UnusedMethodArgument:
AutoCorrect: false

# As above, just flag them.
Lint/UnusedBlockArgument:
AutoCorrect: false
Expand Down Expand Up @@ -179,3 +174,6 @@ Metrics/BlockLength:

Metrics/ClassLength:
Enabled: false

Lint/UnusedMethodArgument:
Enabled: false
4 changes: 2 additions & 2 deletions api/structures/message_api_structure.rb
Expand Up @@ -7,9 +7,9 @@
expansion(:status) do
{
status: o.status,
last_delivery_attempt: o.last_delivery_attempt ? o.last_delivery_attempt.to_f : nil,
last_delivery_attempt: o.last_delivery_attempt&.to_f,
held: o.held,
hold_expiry: o.hold_expiry ? o.hold_expiry.to_f : nil
hold_expiry: o.hold_expiry&.to_f
}
end

Expand Down
12 changes: 5 additions & 7 deletions app/jobs/send_webhook_job.rb
Expand Up @@ -5,14 +5,12 @@ class SendWebhookJob < Postal::Job
def perform
if server = Server.find(params["server_id"])
new_items = {}
if params["payload"]
params["payload"].each do |key, value|
next unless key.to_s =~ /\A_(\w+)/
params["payload"]&.each do |key, value|
next unless key.to_s =~ /\A_(\w+)/

begin
new_items[::Regexp.last_match(1)] = server.message_db.message(value.to_i).webhook_hash
rescue Postal::MessageDB::Message::NotFound
end
begin
new_items[::Regexp.last_match(1)] = server.message_db.message(value.to_i).webhook_hash
rescue Postal::MessageDB::Message::NotFound
end
end

Expand Down
12 changes: 5 additions & 7 deletions app/jobs/unqueue_message_job.rb
Expand Up @@ -430,13 +430,11 @@ def perform
if defined?(Sentry)
Sentry.capture_exception(e, extra: { job_id: self.id, server_id: queued_message.server_id, message_id: queued_message.message_id })
end
if queued_message.message
queued_message.message.create_delivery("Error",
details: "An internal error occurred while sending " \
"this message. This message will be retried " \
"automatically.",
output: "#{e.class}: #{e.message}", log_id: "J-#{self.id}")
end
queued_message.message&.create_delivery("Error",
details: "An internal error occurred while sending " \
"this message. This message will be retried " \
"automatically.",
output: "#{e.class}: #{e.message}", log_id: "J-#{self.id}")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/postal/message_db/message.rb
Expand Up @@ -335,7 +335,7 @@ def headers
# Return the recipient domain for this message
#
def recipient_domain
rcpt_to ? rcpt_to.split("@").last : nil
rcpt_to&.split("@")&.last
end

#
Expand Down
2 changes: 1 addition & 1 deletion lib/postal/smtp_server/client.rb
Expand Up @@ -380,7 +380,7 @@ def data(_data)
else
idata = idata.to_s.sub(/\A\.\./, ".")

if @credential && @credential.server.log_smtp_data?
if @credential&.server&.log_smtp_data?
# We want to log if enabled
else
log "Not logging further message data."
Expand Down

0 comments on commit 00a02f2

Please sign in to comment.