diff --git a/.gitea/workflows/tests.yaml b/.gitea/workflows/tests.yaml
index aea8959..130d1a6 100644
--- a/.gitea/workflows/tests.yaml
+++ b/.gitea/workflows/tests.yaml
@@ -26,7 +26,7 @@ jobs:
# - name: Unit test all packages
# run: pnpm test -r
- test:
+ test_phoenix:
name: Tests & Checks
runs-on: ubuntu-22.04
timeout-minutes: 600
@@ -48,6 +48,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PUBLIC_S3_ENDPOINT: ${{ secrets.PUBLIC_S3_ENDPOINT }}
SITE_URL: https://futureporn.net
+ SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
# @blocking @see https://gitea.com/gitea/act_runner/issues/506
services:
@@ -140,3 +141,11 @@ jobs:
run: |
mix coveralls
working-directory: ./apps/bright
+
+ - name: Check for banned HTML elements (i.e. )
+ run: |
+ if grep -R '' ./lib; then
+ echo "Found banned element '' inside ./lib. Please use <.link> instead."
+ exit 1
+ fi
+ working-directory: ./apps/bright
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index bbcc199..599b0b9 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,7 +1,5 @@
{
"recommendations": [
- "helm-ls.helm-ls",
- "tchoupinax.tilt",
"redhat.vscode-yaml",
"elixir-lsp.elixir-ls"
]
diff --git a/apps/bright/lib/bright/streams.ex b/apps/bright/lib/bright/streams.ex
index e11e6c8..f775a3b 100644
--- a/apps/bright/lib/bright/streams.ex
+++ b/apps/bright/lib/bright/streams.ex
@@ -171,7 +171,7 @@ defmodule Bright.Streams do
def list_vods do
Vod
|> Repo.all()
- |> Repo.preload(:torrent)
+ |> Repo.preload([:torrent, :stream])
end
@doc """
@@ -201,7 +201,7 @@ defmodule Bright.Streams do
def get_vod!(id) do
Vod
|> Repo.get!(id)
- |> Repo.preload(:torrent)
+ |> Repo.preload([:torrent, :stream])
end
@doc """
@@ -222,7 +222,7 @@ defmodule Bright.Streams do
|> Repo.insert()
|> case do
{:ok, %Vod{} = vod} ->
- vod = Repo.preload(vod, [:torrent])
+ vod = Repo.preload(vod, [:torrent, :stream])
Oban.insert!(Bright.ObanWorkers.ProcessVod.new(%{vod_id: vod.id}))
{:ok, vod}
@@ -265,6 +265,7 @@ defmodule Bright.Streams do
"""
def update_vod(%Vod{} = vod, attrs) do
vod
+ |> Repo.preload([:stream, :torrent])
|> Vod.changeset(attrs)
|> Repo.update()
end
diff --git a/apps/bright/lib/bright/torrentfile.ex b/apps/bright/lib/bright/torrentfile.ex
index 64e7da4..921ccc3 100644
--- a/apps/bright/lib/bright/torrentfile.ex
+++ b/apps/bright/lib/bright/torrentfile.ex
@@ -105,7 +105,7 @@ defmodule Bright.Torrentfile do
meta_version
) do
Logger.debug(
- "Torrentfile.create called with args input_path=#{input_path}, output_path=#{output_path}, tracker_url=#{tracker_url}, source_url=#{source_url}, comment=#{comment}, web_seed_url=#{web_seed_url}, meta_version=#{meta_version}"
+ "Torrentfile.create (torrentfile_path()=#{inspect(torrentfile_path())}) called with args input_path=#{input_path}, output_path=#{output_path}, tracker_url=#{tracker_url}, source_url=#{source_url}, comment=#{comment}, web_seed_url=#{web_seed_url}, meta_version=#{meta_version}"
)
case Rambo.run(torrentfile_path(), [
@@ -127,7 +127,7 @@ defmodule Bright.Torrentfile do
input_path
]) do
{:error, reason} -> {:error, reason}
- {:ok, %Rambo{status: 0, out: out, err: ""}} -> {:ok, parse_output(out)}
+ {:ok, %Rambo{status: 0, out: out}} -> {:ok, parse_output(out)}
end
end
diff --git a/apps/bright/priv/repo/migrations/20250212204029_undo_add_platform_id_to_stream.exs b/apps/bright/priv/repo/migrations/20250212204029_undo_add_platform_id_to_stream.exs
new file mode 100644
index 0000000..95f951c
--- /dev/null
+++ b/apps/bright/priv/repo/migrations/20250212204029_undo_add_platform_id_to_stream.exs
@@ -0,0 +1,8 @@
+defmodule Bright.Repo.Migrations.UndoAddPlatformIdToStream do
+ use Ecto.Migration
+
+ def change do
+ # Remove the "Unknown" platform
+ execute("DELETE FROM platforms WHERE id = 1")
+ end
+end
diff --git a/apps/bright/test/bright/platforms_test.exs b/apps/bright/test/bright/platforms_test.exs
index 24c0b2f..18d4ef5 100644
--- a/apps/bright/test/bright/platforms_test.exs
+++ b/apps/bright/test/bright/platforms_test.exs
@@ -8,7 +8,7 @@ defmodule Bright.PlatformsTest do
import Bright.PlatformsFixtures
- @invalid_attrs %{name: nil, url: nil, icon: nil}
+ @invalid_attrs %{name: 7, url: 7, icon: 7}
test "list_platforms/0 returns all platforms" do
platform = platform_fixture()
diff --git a/apps/bright/test/bright/streams_test.exs b/apps/bright/test/bright/streams_test.exs
index 3215035..5acc235 100644
--- a/apps/bright/test/bright/streams_test.exs
+++ b/apps/bright/test/bright/streams_test.exs
@@ -2,6 +2,7 @@ defmodule Bright.StreamsTest do
use Bright.DataCase
alias Bright.Streams
+ require Logger
describe "streams" do
alias Bright.Streams.Stream
@@ -70,9 +71,10 @@ defmodule Bright.StreamsTest do
alias Bright.Streams.Vod
import Bright.StreamsFixtures
+ import Bright.TorrentsFixtures
@invalid_attrs %{
- stream_id: nil,
+ stream_id: "this is very invalid",
s3_cdn_url: nil,
s3_key: nil,
s3_bucket: nil,
@@ -86,8 +88,9 @@ defmodule Bright.StreamsTest do
end
test "get_vod!/1 returns the vod with given id" do
+ torrent = torrent_fixture()
stream = stream_fixture()
- vod = vod_fixture(%{stream_id: stream.id})
+ vod = vod_fixture(%{stream_id: stream.id, torrent_id: torrent.id})
assert Streams.get_vod!(vod.id) == vod
end
@@ -103,8 +106,8 @@ defmodule Bright.StreamsTest do
}
assert {:ok, %Vod{} = vod} = Streams.create_vod(valid_attrs)
+ Logger.debug("just created vod and the vod is vod=#{inspect(vod)}")
assert vod.s3_cdn_url == "some s3_cdn_url"
- assert vod.torrent == "some torrent"
end
test "create_vod/1 with invalid data returns error changeset" do
@@ -119,13 +122,12 @@ defmodule Bright.StreamsTest do
s3_cdn_url: "some updated s3_cdn_url",
s3_upload_id: "some updated s3_upload_id",
s3_key: "some updated s3_key",
- s3_bucket: "some updated s3_bucket",
- torrent: "some updated torrent"
+ s3_bucket: "some updated s3_bucket"
}
assert {:ok, %Vod{} = vod} = Streams.update_vod(vod, update_attrs)
+ Logger.debug("Streams.update_vod just ran, and the vod is vod=#{inspect(vod)}")
assert vod.s3_cdn_url == "some updated s3_cdn_url"
- assert vod.torrent == "some updated torrent"
end
test "update_vod/2 with invalid data returns error changeset" do
@@ -165,6 +167,7 @@ defmodule Bright.StreamsTest do
@tag :integration
@tag :slow
+ @tag timeout: 120_000
test "transmux_to_hls/2" do
stream = stream_fixture()
diff --git a/apps/bright/test/bright/torrentfile_test.exs b/apps/bright/test/bright/torrentfile_test.exs
index 87a7baf..675ed39 100644
--- a/apps/bright/test/bright/torrentfile_test.exs
+++ b/apps/bright/test/bright/torrentfile_test.exs
@@ -26,16 +26,15 @@ defmodule Bright.TorrentfileTest do
test "create/2" do
input_path = @test_ts_fixture
- output_path = Cache.generate_filename("test", "torrent")
stream = stream_fixture()
vod = vod_fixture(%{stream_id: stream.id})
{:ok, output} = Torrentfile.create(vod, input_path)
assert :ok
assert is_binary(output.save_path)
- assert output.save_path === output_path
+ assert output.save_path =~ ".torrent"
assert is_binary(output.btih)
assert is_binary(output.btmh)
- assert File.exists?(output_path)
+ assert File.exists?(output.save_path)
end
test "create/7" do
diff --git a/apps/bright/test/bright/tracker_test.exs b/apps/bright/test/bright/tracker_test.exs
index 90529b4..4b64ec1 100644
--- a/apps/bright/test/bright/tracker_test.exs
+++ b/apps/bright/test/bright/tracker_test.exs
@@ -1,4 +1,5 @@
defmodule Bright.TrackerTest do
+ require Logger
use Bright.DataCase
alias Bright.Tracker
@@ -13,9 +14,17 @@ defmodule Bright.TrackerTest do
@tag :integration
test "whitelist_info_hash/1 using a string info_hash" do
- {:ok, result} = Tracker.whitelist_info_hash(@info_hash_v1_fixture)
- assert :ok
- assert result === "Successfully added to whitelist"
+ case Tracker.whitelist_info_hash(@info_hash_v1_fixture) do
+ {:ok, result} ->
+ assert :ok
+ assert result === "Successfully added to whitelist"
+
+ {:error, :closed} ->
+ flunk("The connection to opentracker was closed. Is opentracker running?")
+
+ other ->
+ flunk("Unexpected result: #{inspect(other)}")
+ end
end
@tag :integration
@@ -26,8 +35,19 @@ defmodule Bright.TrackerTest do
assert is_map(body) or is_list(body)
{:error, "Requested download is not authorized for use with this tracker."} ->
+ Logger.warning(
+ "info_hash '#{@info_hash_v1_fixture}' is not on the tracker's whitelist."
+ )
+
+ Logger.warning(
+ "Since this is an integration test, and the tracker behavior is not the unit under test, we are passing the test."
+ )
+
assert true
+ {:error, :closed} ->
+ flunk("The connection to opentracker was closed. Is opentracker running?")
+
other ->
flunk("Unexpected result: #{inspect(other)}")
end
diff --git a/packages/opentracker/root/etc/caddy/Caddyfile b/packages/opentracker/root/etc/caddy/Caddyfile
index 67094f4..83889c6 100644
--- a/packages/opentracker/root/etc/caddy/Caddyfile
+++ b/packages/opentracker/root/etc/caddy/Caddyfile
@@ -1,16 +1,18 @@
{
- auto_https off
- admin off
- http_port 8666
+ auto_https off
+ admin off
+ http_port 8666
}
+
+
:8666 {
- reverse_proxy 127.0.0.1:6969
+ reverse_proxy 127.0.0.1:6969
- route /whitelist* {
- basic_auth /whitelist {
- {$WHITELIST_USERNAME} {$WHITELIST_PASSWORD_CADDY}
- }
- reverse_proxy 127.0.0.1:3001
- }
-}
+ route /whitelist* {
+ basic_auth /whitelist {
+ {$WHITELIST_USERNAME} {$WHITELIST_PASSWORD_CADDY}
+ }
+ reverse_proxy 127.0.0.1:3001
+ }
+}
\ No newline at end of file
diff --git a/packages/opentracker/root/etc/s6-overlay/s6-rc.d/svc-caddy/run b/packages/opentracker/root/etc/s6-overlay/s6-rc.d/svc-caddy/run
index 360c902..06afbb1 100644
--- a/packages/opentracker/root/etc/s6-overlay/s6-rc.d/svc-caddy/run
+++ b/packages/opentracker/root/etc/s6-overlay/s6-rc.d/svc-caddy/run
@@ -4,12 +4,12 @@
# curl -sS --request GET --url "${WHITELIST_FEED_URL}" --header 'accept: text/plain' -o /etc/opentracker/whitelist
-# exec 2>&1
-# exec /bin/opentracker -f /etc/opentracker/opentracker.conf
-
echo "Loading torrent whitelist from ${WHITELIST_FEED_URL}"
curl -sS --request GET --url "${WHITELIST_FEED_URL}" --header 'accept: text/plain' -o /etc/opentracker/whitelist
echo "Starting caddy"
-/usr/bin/caddy run --config /etc/caddy/Caddyfile
\ No newline at end of file
+exec 2>&1
+exec /usr/bin/caddy run --config /etc/caddy/Caddyfile
+
+