Prefix fire-and-forget calls (PubSub.broadcast, Oban enqueue, Logger, update_*, etc.) with `_ =` so dialyzer knows the return value is intentionally discarded. Wrap a few if/case expressions whose branches produce mixed types the same way. No behavior changes — only explicit acknowledgement of discarded returns. Warnings: 242 → 88.
34 lines
753 B
Elixir
34 lines
753 B
Elixir
defmodule Towerops.Workers.WelcomeEmailWorker do
|
|
@moduledoc """
|
|
Sends a welcome email to new users a few minutes after registration.
|
|
"""
|
|
use Oban.Worker,
|
|
queue: :notifications,
|
|
max_attempts: 3
|
|
|
|
alias Towerops.Accounts
|
|
alias Towerops.Accounts.UserNotifier
|
|
|
|
require Logger
|
|
|
|
@delay_minutes 3
|
|
|
|
@impl Oban.Worker
|
|
def perform(%Oban.Job{args: %{"user_id" => user_id}}) do
|
|
case Accounts.get_user(user_id) do
|
|
nil ->
|
|
Logger.warning("Welcome email skipped: user #{user_id} not found")
|
|
:ok
|
|
|
|
user ->
|
|
_ = UserNotifier.deliver_welcome_email(user)
|
|
:ok
|
|
end
|
|
end
|
|
|
|
def enqueue(user_id) do
|
|
%{user_id: user_id}
|
|
|> new(schedule_in: @delay_minutes * 60)
|
|
|> Oban.insert()
|
|
end
|
|
end
|