Skip to content

Commit 4cd73eb

Browse files
committed
fix: Various minor type bugs found by Elixir's type checker
1 parent 2aae4ac commit 4cd73eb

16 files changed

Lines changed: 46 additions & 36 deletions

File tree

‎config/runtime.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ if config_env() == :prod do
111111
For example: ecto://USER:PASS@HOST/DATABASE
112112
"""
113113

114-
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
115-
116114
config :octocon, :proxy_db, System.get_env("OCTO_PROXY_DB") in ~w(true 1)
117115

118116
config :octocon, Octocon.Repo,

‎fly.toml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ processes = ['auxiliary', 'sidecar']
5252
[[vm]]
5353
memory = '1gb'
5454
cpu_kind = 'shared'
55-
cpus = 2
55+
cpus = 1
5656
# processes = ['primary', 'auxiliary', 'sidecar']
57-
processes = ['auxiliary', 'sidecar']
57+
processes = ['auxiliary']
58+
59+
[[vm]]
60+
memory = '1gb'
61+
cpu_kind = 'shared'
62+
cpus = 2
63+
processes = ['sidecar']
5864

5965
[[services]]
6066
internal_port = 41641

‎lib/octocon/accounts/user.ex‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ defmodule Octocon.Accounts.User do
2121
import Ecto.Changeset
2222
import Exandra, only: [embedded_type: 3]
2323

24-
alias Octocon.Accounts.DiscordSettings
25-
2624
@primary_key false
2725

2826
schema "users" do

‎lib/octocon/alters.ex‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ defmodule Octocon.Alters do
201201
security_level =
202202
case alter do
203203
{:ok, alter} -> alter.security_level
204-
{:error, :no_alter} -> :private
204+
{:error, :no_alter_id} -> :private
205+
{:error, :no_alter_alias} -> :private
205206
end
206207

207-
if can_view_entity?(friendship_level, security_level) and alter != {:error, :no_alter} do
208+
if can_view_entity?(friendship_level, security_level) and alter != {:error, :no_alter_id} and alter != {:error, :no_alter_alias} do
208209
{:ok, alter} = alter
209210
fields = get_guarded_fields(user_fields, alter.fields || [], friendship_level)
210211
{:ok, %{alter | fields: fields}}
@@ -330,7 +331,7 @@ defmodule Octocon.Alters do
330331
{:error, :database}
331332
end
332333
rescue
333-
e ->
334+
_ ->
334335
if force_id == nil do
335336
# Manually resync the user's alter count
336337
highest_alter_id = get_highest_alter_id({:system, user.id})

‎lib/octocon/application.ex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule Octocon.Application do
3030
Logger.warning("Starting node of type: #{group}")
3131

3232
children =
33-
global_children(group) ++
33+
global_children() ++
3434
group_children(group) ++
3535
[
3636
# Web endpoint
@@ -50,7 +50,7 @@ defmodule Octocon.Application do
5050
:ok
5151
end
5252

53-
defp global_children(group) do
53+
defp global_children() do
5454
topologies = [
5555
tailscale: [
5656
strategy: Cluster.Strategy.Tailscale,

‎lib/octocon/friendships.ex‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ defmodule Octocon.Friendships do
1616
alias Octocon.Friendships.Friendship
1717
alias Octocon.Fronts
1818

19-
alias Octocon.Fronts.{
20-
CurrentFront,
21-
Front
22-
}
19+
alias Octocon.Fronts.CurrentFront
2320

2421
@doc """
2522
Returns the friendship status between two users with the given identities, or `nil` if no friendship exists.
@@ -44,10 +41,14 @@ defmodule Octocon.Friendships do
4441
)
4542
|> Repo.one_regional({:user, {:system, friend_id}})
4643

47-
%{
48-
friendship: friendship,
49-
friend: friend
50-
}
44+
if friendship == nil do
45+
nil
46+
else
47+
%{
48+
friendship: friendship,
49+
friend: friend
50+
}
51+
end
5152
end
5253

5354
@doc """
@@ -479,6 +480,9 @@ defmodule Octocon.Friendships do
479480
{:error, :database}
480481
end
481482

483+
Accounts.get_user({:system, Accounts.id_from_system_identity(to_identity, :system)}) == nil ->
484+
{:error, :no_user}
485+
482486
true ->
483487
{:error, :not_requested}
484488
end
@@ -512,6 +516,9 @@ defmodule Octocon.Friendships do
512516

513517
:ok
514518

519+
Accounts.get_user({:system, Accounts.id_from_system_identity(to_identity, :system)}) == nil ->
520+
{:error, :no_user}
521+
515522
true ->
516523
{:error, :not_requested}
517524
end

‎lib/octocon/fronts.ex‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ defmodule Octocon.Fronts do
537537
)
538538
end)
539539

540-
%Front{
540+
front = %Front{
541541
id: id,
542542
user_id: system_id,
543543
alter_id: alter_id,
@@ -569,6 +569,8 @@ defmodule Octocon.Fronts do
569569
Octocon.Global.FrontNotifier.set(system_id, alter_id)
570570
end)
571571
end)
572+
573+
{:ok, front}
572574
end
573575
end
574576

‎lib/octocon/fronts/front.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ end
149149
defmodule Octocon.Fronts.FrontByEndTime do
150150
@moduledoc false
151151
use Ecto.Schema
152-
import Ecto.Changeset
153152

154153
@primary_key false
155154

‎lib/octocon/tags.ex‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ defmodule Octocon.Tags do
422422
{:error, :not_found}
423423

424424
{count, _} when count > 0 ->
425-
system_id = Accounts.id_from_system_identity(system_identity, :system)
426-
425+
# system_id = Accounts.id_from_system_identity(system_identity, :system)
427426
# spawn(fn ->
428427
# OctoconWeb.Endpoint.broadcast!(
429428
# "system:#{system_id}",

‎lib/octocon/workers/simply_plural_import_worker.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ defmodule Octocon.Workers.SimplyPluralImportWorker do
2020
@sp_endpoint URI.parse("https://api.apparyllis.com/v1/")
2121
@cdn_endpoint URI.parse("https://spaces.apparyllis.com/")
2222

23-
@impl true
2423
def perform(%{"system_id" => system_id, "sp_token" => sp_token}) do
2524
Logger.warning("Performing Simply Plural import for user #{system_id}")
2625

0 commit comments

Comments
 (0)