diff --git a/.tool-versions b/.tool-versions index 05859a0..35cd3ec 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,3 @@ +erlang 21.1 elixir 1.7.4-otp-21 nodejs 10.11.0 diff --git a/Dockerfile b/Dockerfile index 075086c..f280381 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM elixir:1.7.3 +FROM elixir:1.7.4 as build ARG MIX_ENV=prod ENV MIX_ENV ${MIX_ENV} @@ -24,7 +24,7 @@ RUN mix compile RUN mix release --env=${MIX_ENV} --verbose \ && mv _build/${MIX_ENV}/rel/courtbot /opt/release -FROM debian:stretch +FROM debian:stretch as runtime ENV LANG en_US.UTF-8 ENV LC_CTYPE en_US.UTF-8 @@ -37,5 +37,5 @@ RUN locale-gen en_US.UTF-8 RUN localedef -i en_US -f UTF-8 en_US.UTF-8 WORKDIR /opt/app -COPY --from=0 /opt/release . +COPY --from=build /opt/release . CMD trap 'exit' INT; /opt/app/bin/courtbot foreground diff --git a/README.md b/README.md index df22595..8ae5a05 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Courtbot -[![Build Status](https://travis-ci.org/boisebrigade/courtbot.svg?branch=development)](https://travis-ci.org/boisebrigade/Courtbot) +[![Build Status](https://travis-ci.org/boisebrigade/courtbot.svg?branch=development)](https://travis-ci.org/boisebrigade/courtbot) Courtbot is a simple web service for subscribing to case hearing details via SMS. diff --git a/docker-deploy.sh b/docker-deploy.sh deleted file mode 100755 index be941a1..0000000 --- a/docker-deploy.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -docker build -t codeforboise/courtbot:latest . -# docker push codeforboise/courtbot:latest diff --git a/lib/courtbot/release.ex b/lib/courtbot/release.ex index 4699cf4..a9cb184 100644 --- a/lib/courtbot/release.ex +++ b/lib/courtbot/release.ex @@ -3,11 +3,12 @@ defmodule Courtbot.ReleaseTasks do :crypto, :ssl, :postgrex, + :ecto, :ecto_sql, :timex ] - @repos Application.get_env(:courtbot, :ecto_repos, []) + @repo Courtbot.Repo def migrate() do start_services() @@ -17,6 +18,24 @@ defmodule Courtbot.ReleaseTasks do stop_services() end + def seeders() do + start_services() + + run_seeds() + + stop_services() + end + + defp run_seeds() do + # Run the seed script if it exists + seed_script = priv_path_for(@repo, "seeds.exs") + + if File.exists?(seed_script) do + IO.puts("Running seed script..") + Code.eval_file(seed_script) + end + end + def import() do start_services() @@ -33,6 +52,54 @@ defmodule Courtbot.ReleaseTasks do stop_services() end + def reset() do + drop_database() + create_database() + + start_services() + + create_migrations_table() + run_migrations() + + stop_services() + end + + defp create_migrations_table() do + Ecto.Migration.SchemaMigration.ensure_schema_migrations_table!(@repo, nil) + end + + defp drop_database() do + case @repo.__adapter__.storage_down(@repo.config) do + :ok -> + IO.puts("Database has been dropped") + + {:error, :already_down} -> + IO.puts("Dtabase has already been dropped") + + {:error, term} when is_binary(term) -> + raise "Database couldn't be dropped: #{term}" + + {:error, term} -> + raise "Database couldn't be dropped: #{inspect(term)}" + end + end + + defp create_database() do + case @repo.__adapter__.storage_up(@repo.config) do + :ok -> + IO.puts("Database has been created") + + {:error, :already_up} -> + IO.puts("Database has already been created") + + {:error, term} when is_binary(term) -> + raise "Database couldn't be created: #{term}" + + {:error, term} -> + raise "Database couldn't be created: #{inspect(term)}" + end + end + defp start_services do IO.puts("Starting dependencies..") # Start apps necessary for executing migrations @@ -40,7 +107,8 @@ defmodule Courtbot.ReleaseTasks do # Start the Repo(s) for app IO.puts("Starting repos..") - Enum.each(@repos, & &1.start_link(pool_size: 2)) + + @repo.start_link(pool_size: 2) end defp stop_services do @@ -49,7 +117,7 @@ defmodule Courtbot.ReleaseTasks do end defp run_migrations do - Enum.each(@repos, &run_migrations_for/1) + run_migrations_for(Courtbot.Repo) end defp run_migrations_for(repo) do diff --git a/lib/courtbot_web/controllers/twiliocontroller.ex b/lib/courtbot_web/controllers/twiliocontroller.ex index 5cff434..11579c9 100644 --- a/lib/courtbot_web/controllers/twiliocontroller.ex +++ b/lib/courtbot_web/controllers/twiliocontroller.ex @@ -35,6 +35,8 @@ defmodule CourtbotWeb.TwilioController do gettext("unsubscribe") ] + @county gettext("county") + @request_defaults %{"locale" => "en"} def sms(conn, _ = %{"From" => phone_number, "Body" => @debug_phase}) do @@ -148,6 +150,11 @@ defmodule CourtbotWeb.TwilioController do "requires_county" => case_number } ) do + message = + message + |> String.replace(@county, "") + |> String.trim() + if Enum.member?(Case.all_counties(), message) do {_, params} = params @@ -251,7 +258,7 @@ defmodule CourtbotWeb.TwilioController do defp respond(conn, params, [case = %Case{hearings: _}]), do: prompt_remind(conn, params, case) defp respond(conn, params, [_ | _]), do: prompt_county(conn, params) - defp respond(conn, params, _), do: prompt_unfound(conn, params) + defp respond(conn, params, _), do: prompt_not_found(conn, params) defp prompt_no_hearings(conn, params = %{"From" => phone_number}, case) do Logger.info( @@ -266,7 +273,7 @@ defmodule CourtbotWeb.TwilioController do |> encode(response) end - defp prompt_unfound(conn, params = %{"From" => phone_number, "message" => message}) do + defp prompt_not_found(conn, params = %{"From" => phone_number, "message" => message}) do Logger.info(log_safe_phone_number(phone_number) <> ": No case found for input: #{message}") response = Response.message(:not_found, params) diff --git a/lib/courtbot_web/endpoint.ex b/lib/courtbot_web/endpoint.ex index 535e388..4f4f3c4 100644 --- a/lib/courtbot_web/endpoint.ex +++ b/lib/courtbot_web/endpoint.ex @@ -40,8 +40,7 @@ defmodule CourtbotWeb.Endpoint do """ def init(_key, config) do if config[:load_from_system_env] do - port = String.to_integer(System.get_env("PORT")) || 4000 - host = System.get_env("HOST") || "localhost" + port = String.to_integer(System.get_env("PORT") || "4000") secret_key_base = if config[:secret_key_base] do @@ -53,16 +52,19 @@ defmodule CourtbotWeb.Endpoint do config = config - |> Keyword.put(:http, port: port) - |> Keyword.put(:url, port: port, host: host) |> Keyword.put(:secret_key_base, secret_key_base) - # If we are trying to mount to 443 then set HTTPS specific settings config = - if port === 443 do - config - |> Keyword.put(:url, scheme: "https") - |> Keyword.put(:force_ssl, rewrite_on: [:x_forwarded_proto]) + if config[:server] do + # If we are trying to mount to 443 then set HTTPS specific settings + if port === 443 do + config + |> Keyword.put(:https, port: port, host: {0, 0, 0, 0}) + |> Keyword.put(:force_ssl, rewrite_on: [:x_forwarded_proto]) + else + config + |> Keyword.put(:http, port: port, host: {0, 0, 0, 0}) + end else config end diff --git a/lib/courtbot_web/response.ex b/lib/courtbot_web/response.ex index 4d29dec..c7d25d5 100644 --- a/lib/courtbot_web/response.ex +++ b/lib/courtbot_web/response.ex @@ -74,7 +74,7 @@ defmodule CourtbotWeb.Response do defp response(:prompt_reminder, %{"locale" => locale}) do Gettext.with_locale(locale, fn -> - gettext("Would you like a reminder 24hr before the hearing date?") + gettext("Would you like a reminder a day before the next hearing date?") end) end @@ -88,7 +88,9 @@ defmodule CourtbotWeb.Response do defp response(:reject_reminder, %{"locale" => locale}) do Gettext.with_locale(locale, fn -> - gettext("You said “No” so we won’t text you a reminder.") + gettext( + "Ok. We won't send you a reminder for this case. Text the case again in the future and you can subscribe." + ) end) end diff --git a/mix.exs b/mix.exs index 0a0020e..b026956 100644 --- a/mix.exs +++ b/mix.exs @@ -41,12 +41,13 @@ defmodule Courtbot.Mixfile do {:cloak, "~> 0.7.0"}, {:gettext, "~> 0.11"}, {:csv, "~> 2.0.0"}, + {:jason, "~> 1.1"}, {:aes256, "~> 0.5.0"}, {:sched_ex, "~> 1.0"}, {:tesla, "~> 1.0.0"}, {:timex, "~> 3.1"}, {:plug_cowboy, "~> 2.0"}, - {:ex_twilio, "~> 0.6.0", runtime: false}, + {:ex_twilio, "~> 0.6.0"}, {:ex_twiml, "~> 2.1.3"}, {:rollbax, ">= 0.0.0"}, {:ex_doc, "~> 0.18.0", only: :dev, runtime: false}, diff --git a/mix.lock b/mix.lock index adbaad1..8402963 100644 --- a/mix.lock +++ b/mix.lock @@ -1,45 +1,37 @@ %{ - "absinthe": {:hex, :absinthe, "1.4.13", "81eb2ff41f1b62cd6e992955f62c22c042d1079b7936c27f5f7c2c806b8fc436", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, - "absinthe_plug": {:hex, :absinthe_plug, "1.4.6", "ac5d2d3d02acf52fda0f151b294017ab06e2ed1c6c15334e06aac82c94e36e08", [:mix], [{:absinthe, "~> 1.4.11", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.2 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "absinthe_relay": {:hex, :absinthe_relay, "1.4.4", "d0a6d8e71375a6026974d227456c8a73ea8eea7c7b00e698603ab5a96066c333", [:mix], [{:absinthe, "~> 1.4.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "aes256": {:hex, :aes256, "0.5.1", "bf8a21c2d5642da93e181d3494636507e78f40e479c7df3d49e577e2cf352517", [:mix], [], "hexpm"}, "artificery": {:hex, :artificery, "0.2.6", "f602909757263f7897130cbd006b0e40514a541b148d366ad65b89236b93497a", [:mix], [], "hexpm"}, "base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], [], "hexpm"}, - "bcrypt_elixir": {:hex, :bcrypt_elixir, "0.12.1", "41ff5a4739fcff365fe840637462dc9e22beac07a9dcf3cb5e79b127f5b3a099", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "cloak": {:hex, :cloak, "0.7.0", "3257357acd51e55eb08d00a41ca3e2ab2c83b8d6561633b1cee7262c5f6be527", [:mix], [{:ecto, ">= 1.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:flow, "~> 0.13", [hex: :flow, repo: "hexpm", optional: false]}, {:pbkdf2, "~> 2.0", [hex: :pbkdf2, repo: "hexpm", optional: true]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"}, - "comeonin": {:hex, :comeonin, "4.1.1", "c7304fc29b45b897b34142a91122bc72757bc0c295e9e824999d5179ffc08416", [:mix], [{:argon2_elixir, "~> 1.2", [hex: :argon2_elixir, repo: "hexpm", optional: true]}, {:bcrypt_elixir, "~> 0.12.1 or ~> 1.0", [hex: :bcrypt_elixir, repo: "hexpm", optional: true]}, {:pbkdf2_elixir, "~> 0.12", [hex: :pbkdf2_elixir, repo: "hexpm", optional: true]}], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, - "cowboy": {:hex, :cowboy, "2.5.0", "4ef3ae066ee10fe01ea3272edc8f024347a0d3eb95f6fbb9aed556dacbfc1337", [:rebar3], [{:cowlib, "~> 2.6.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.6.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, - "cowlib": {:hex, :cowlib, "2.6.0", "8aa629f81a0fc189f261dc98a42243fa842625feea3c7ec56c48f4ccdb55490f", [:rebar3], [], "hexpm"}, - "crontab": {:hex, :crontab, "1.1.4", "eae8de759d60dec2352ca577890f4cac26bcb907088ffef958f42ebb9c4f4cff", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, + "cowboy": {:hex, :cowboy, "2.6.1", "f2e06f757c337b3b311f9437e6e072b678fcd71545a7b2865bdaa154d078593f", [:rebar3], [{:cowlib, "~> 2.7.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, + "cowlib": {:hex, :cowlib, "2.7.0", "3ef16e77562f9855a2605900cedb15c1462d76fb1be6a32fc3ae91973ee543d2", [:rebar3], [], "hexpm"}, + "crontab": {:hex, :crontab, "1.1.5", "2c9439506ceb0e9045de75879e994b88d6f0be88bfe017d58cb356c66c4a5482", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "csv": {:hex, :csv, "2.0.0", "c66fea89ba7862b94901baf0871285e9b73cad89c5fdb57a6386d2adcf29593e", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, repo: "hexpm", optional: false]}], "hexpm"}, - "db_connection": {:hex, :db_connection, "2.0.1", "09454c6c6e8e4295f400b72580b19f0ac68fda2602e209533285206cb99bee6b", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"}, + "db_connection": {:hex, :db_connection, "2.0.3", "b4e8aa43c100e16f122ccd6798cd51c48c79fd391c39d411f42b3cd765daccb0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, + "decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"}, "distillery": {:hex, :distillery, "2.0.12", "6e78fe042df82610ac3fa50bd7d2d8190ad287d120d3cd1682d83a44e8b34dfb", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "3.0.1", "a26605ee7b243a754e6609d1c23da27bcb22823659b07bf03f9020da92a8e4f4", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, - "ecto_sql": {:hex, :ecto_sql, "3.0.0", "8d1883376bee02a0e76b5ef797e39d04333c34b9935d0b4785dbf3cbdb571e2a", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, - "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"}, - "elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"}, + "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, + "ecto": {:hex, :ecto, "3.0.5", "bf9329b56f781a67fdb19e92e6d9ed79c5c8b31d41653b79dafb7ceddfbe87e0", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, + "ecto_sql": {:hex, :ecto_sql, "3.0.3", "dd17f2401a69bb2ec91d5564bd259ad0bc63ee32c2cb2e616d04f1559801dba6", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.18.4", "4406b8891cecf1352f49975c6d554e62e4341ceb41b9338949077b0d4a97b949", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, "ex_twilio": {:hex, :ex_twilio, "0.6.1", "2c2b65f21eeb9b88532202280c6c064c2f6241f2d520d7992941504d12dbf8de", [:mix], [{:httpoison, ">= 0.9.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:inflex, "~> 1.0", [hex: :inflex, repo: "hexpm", optional: false]}, {:joken, "~> 1.5", [hex: :joken, repo: "hexpm", optional: false]}, {:poison, "~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "ex_twiml": {:hex, :ex_twiml, "2.1.3", "1291af09994cdf6731b4e624ae869c1e093b223ca4fceb1599b0af9d66c1afee", [:mix], [], "hexpm"}, "file_system": {:hex, :file_system, "0.2.6", "fd4dc3af89b9ab1dc8ccbcc214a0e60c41f34be251d9307920748a14bf41f1d3", [:mix], [], "hexpm"}, "flow": {:hex, :flow, "0.14.3", "0d92991fe53035894d24aa8dec10dcfccf0ae00c4ed436ace3efa9813a646902", [:mix], [{:gen_stage, "~> 0.14.0", [hex: :gen_stage, repo: "hexpm", optional: false]}], "hexpm"}, "gen_stage": {:hex, :gen_stage, "0.14.1", "9d46723fda072d4f4bb31a102560013f7960f5d80ea44dcb96fd6304ed61e7a4", [:mix], [], "hexpm"}, - "gettext": {:hex, :gettext, "0.16.0", "4a7e90408cef5f1bf57c5a39e2db8c372a906031cc9b1466e963101cb927dafc", [:mix], [], "hexpm"}, - "guardian": {:hex, :guardian, "0.14.6", "99c3996b9c937cfc0ee98b0f4415ee05765c9587af74841dc516d45407de1686", [:mix], [{:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.2 and < 1.4.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.3", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, ">= 1.3.0 and < 4.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "httpoison": {:hex, :httpoison, "1.4.0", "e0b3c2ad6fa573134e42194d13e925acfa8f89d138bc621ffb7b1989e6d22e73", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "httpoison": {:hex, :httpoison, "1.5.0", "71ae9f304bdf7f00e9cd1823f275c955bdfc68282bc5eb5c85c3a9ade865d68e", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "inflex": {:hex, :inflex, "1.10.0", "8366a7696e70e1813aca102e61274addf85d99f4a072b2f9c7984054ea1b9d29", [:mix], [], "hexpm"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, "joken": {:hex, :joken, "1.5.0", "42a0953e80bd933fc98a0874e156771f78bf0e92abe6c3a9c22feb6da28efb0b", [:mix], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, "jose": {:hex, :jose, "1.8.4", "7946d1e5c03a76ac9ef42a6e6a20001d35987afd68c2107bcd8f01a84e75aa73", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "mix_test_watch": {:hex, :mix_test_watch, "0.9.0", "c72132a6071261893518fa08e121e911c9358713f62794a90c95db59042af375", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"}, "parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm"}, @@ -48,13 +40,13 @@ "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"}, "plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"}, - "plug_cowboy": {:hex, :plug_cowboy, "2.0.0", "ab0c92728f2ba43c544cce85f0f220d8d30fc0c90eaa1e6203683ab039655062", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "plug_cowboy": {:hex, :plug_cowboy, "2.0.1", "d798f8ee5acc86b7d42dbe4450b8b0dadf665ce588236eb0a751a132417a980e", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, - "postgrex": {:hex, :postgrex, "0.14.0", "f3d6ffea1ca8a156e0633900a5338a3d17b00435227726baed8982718232b694", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "ranch": {:hex, :ranch, "1.6.2", "6db93c78f411ee033dbb18ba8234c5574883acb9a75af0fb90a9b82ea46afa00", [:rebar3], [], "hexpm"}, + "postgrex": {:hex, :postgrex, "0.14.1", "63247d4a5ad6b9de57a0bac5d807e1c32d41e39c04b8a4156a26c63bcd8a2e49", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, + "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"}, "rollbax": {:hex, :rollbax, "0.9.2", "ba21f4899d7f752bd7a110db72b60f4c06eeb5bbe2b5f1a86e89efe0f832221e", [:mix], [{:hackney, "~> 1.1", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "sched_ex": {:hex, :sched_ex, "1.0.2", "c471aee0275c2cd16f49afd601c3408e50cacfe8df7f119003d58ce233690c2f", [:mix], [{:crontab, "~> 1.1.2", [hex: :crontab, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"}, + "sched_ex": {:hex, :sched_ex, "1.0.3", "90fe5c145689e59ab4e41bf48aa1a3195a9fcdd7f38231ca219e660724090440", [:mix], [{:crontab, "~> 1.1.2", [hex: :crontab, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, "telemetry": {:hex, :telemetry, "0.2.0", "5b40caa3efe4deb30fb12d7cd8ed4f556f6d6bd15c374c2366772161311ce377", [:mix], [], "hexpm"}, "tesla": {:hex, :tesla, "1.0.0", "94a9059456d51266f3d40b75ff6be3d18496072ce5ffaabad03d6c00f065cfd1", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 5041b6c..f7da7a3 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -1,7 +1,10 @@ alias Courtbot.{Case, Repo} # Debug case. This case can be used to do a health check. -%Case{ - case_number: "BEEPBOOP", - formatted_case_number: "BEEPBOOP" -} |> Repo.insert! + +if Case.find_by_case_number("BEEPBOOP") === [] do + %Courtbot.Case{ + case_number: "BEEPBOOP", + formatted_case_number: "BEEPBOOP" + } |> Courtbot.Repo.insert! +end diff --git a/rel/commands/reset b/rel/commands/reset new file mode 100755 index 0000000..9e59587 --- /dev/null +++ b/rel/commands/reset @@ -0,0 +1,3 @@ +#!/bin/sh + +release_remote_ctl eval --mfa "Courtbot.ReleaseTasks.reset/0" diff --git a/rel/config.exs b/rel/config.exs index cb45d23..f3e083d 100644 --- a/rel/config.exs +++ b/rel/config.exs @@ -48,7 +48,8 @@ release :courtbot do set( commands: [ import: "rel/commands/import", - notify: "rel/commands/notify" + notify: "rel/commands/notify", + reset: "rel/commands/reset" ] ) diff --git a/rel/hooks/pre_configure.d/00_secrets.sh b/rel/hooks/pre_configure.d/00_secrets.sh index 5f76f16..75fcf4a 100755 --- a/rel/hooks/pre_configure.d/00_secrets.sh +++ b/rel/hooks/pre_configure.d/00_secrets.sh @@ -5,7 +5,9 @@ SECRET_KEY_BASE=$(tr -dc 'A-F0-9' < /dev/urandom | head -c64) VAULT_KEY=$(tr -dc 'A-F0-9' < /dev/urandom | head -c32 | base64) # If we don't have a secrets file, then make one. -[ ! -f ${RELEASE_ROOT_DIR}/etc/courtbot.secrets.exs ] && cat > ${RELEASE_ROOT_DIR}/etc/courtbot.secrets.exs < ${RELEASE_ROOT_DIR}/etc/courtbot.secrets.exs <