diff --git a/.github/workflows/on_push_branch__execute_tests.yml b/.github/workflows/on_push_branch__execute_tests.yml index 98eb82b..419164e 100644 --- a/.github/workflows/on_push_branch__execute_tests.yml +++ b/.github/workflows/on_push_branch__execute_tests.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 # we need cmake for fast_sanitize: - - run: apt-get -y update && apt-get -y install git build-essential cmake + - run: apt-get -y update && apt-get -y install build-essential cmake # install hex: - run: mix local.hex --force && mix local.rebar --force @@ -75,8 +75,8 @@ jobs: steps: # Downloads a copy of the code in your repository before running CI tests - uses: actions/checkout@v4 - # we need git so that mix can access our own repo and cmake for fast_sanitize: - - run: apt-get -y update && apt-get -y install git build-essential cmake + # we need cmake for fast_sanitize: + - run: apt-get -y update && apt-get -y install build-essential cmake - uses: actions/cache@v4 with: path: | @@ -103,9 +103,6 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - # we need git so that mix can access our own repo: - - run: apt-get -y update && apt-get -y install git - # install hex: - run: mix local.hex --force && mix local.rebar --force @@ -128,9 +125,6 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v4 - - # we need git so that mix can access our own repo: - - run: apt-get -y update && apt-get -y install git # install hex: - run: mix local.hex --force && mix local.rebar --force diff --git a/lib/qrstorage/services/rate_limiting_service.ex b/lib/qrstorage/services/rate_limiting_service.ex index b651c96..070b161 100644 --- a/lib/qrstorage/services/rate_limiting_service.ex +++ b/lib/qrstorage/services/rate_limiting_service.ex @@ -21,6 +21,11 @@ defmodule Qrstorage.Services.RateLimitingService do defp audio_character_count_in_timeframe(qr_code) do # We start with 24 - we can make this configurable later hours = 24 + + # The logic here is quite fuzzy for the sake of simplicity. It is likely that we will actually count qr_code text length twic: + # In the current implementation, we save the qr_code first, then apply all checks, then delete if necessary. + # However, we still add the text length there again to make sure the rate limit still works, even when we change this behaviour in the future. + # Therefore, the limit is actually a bit lower than the configured limit past_audio_character_count = QrCodes.audio_character_count_in_last_hours(hours) String.length(qr_code.text) + past_audio_character_count end diff --git a/mix.exs b/mix.exs index 11729c9..70e9274 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Qrstorage.MixProject do def project do [ app: :qrstorage, - version: "0.2.1", + version: "0.3.0", elixir: "~> 1.11", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, @@ -59,7 +59,7 @@ defmodule Qrstorage.MixProject do {:ex_aws_s3, "2.5.3"}, {:cloak, "1.1.4"}, {:sobelow, "0.13.0", only: [:dev, :test], runtime: false}, - {:deepl_ex, git: "https://github.com/b310-digital/deepl_ex.git", branch: "60-allow-detection-of-source-language"}, + {:deepl_ex, "0.4.0"}, {:tesla, "1.12.1"} ] end diff --git a/mix.lock b/mix.lock index 07dca0a..1269033 100644 --- a/mix.lock +++ b/mix.lock @@ -9,7 +9,7 @@ "dart_sass": {:hex, :dart_sass, "0.7.0", "7979e056cb74fd6843e1c72db763cffc7726a9192a657735b7d24c0d9c26a1ce", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "4a8e70bca41aa00846398abdf5ad8a64d7907a0f7bf40145cd2e40d5971629f2"}, "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, - "deepl_ex": {:git, "https://github.com/b310-digital/deepl_ex.git", "ee26d94aba2806c91ed6a37839392fae10d30190", [branch: "60-allow-detection-of-source-language"]}, + "deepl_ex": {:hex, :deepl_ex, "0.4.0", "bb9c931348eeca176e48a513474880874f535f7745c462e8d322e103aefeeefc", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:tesla, "~> 1.7", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "44759f743ec6fdd7ed972250a4f3df9fa8090064dc8401d37a919d1c47138ca7"}, "ecto": {:hex, :ecto, "3.12.1", "626765f7066589de6fa09e0876a253ff60c3d00870dd3a1cd696e2ba67bfceea", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "df0045ab9d87be947228e05a8d153f3e06e0d05ab10c3b3cc557d2f7243d1940"}, "ecto_sql": {:hex, :ecto_sql, "3.12.0", "73cea17edfa54bde76ee8561b30d29ea08f630959685006d9c6e7d1e59113b7d", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dc9e4d206f274f3947e96142a8fdc5f69a2a6a9abb4649ef5c882323b6d512f0"}, "elixir_make": {:hex, :elixir_make, "0.7.8", "505026f266552ee5aabca0b9f9c229cbb496c689537c9f922f3eb5431157efc7", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "7a71945b913d37ea89b06966e1342c85cfe549b15e6d6d081e8081c493062c07"},