Skip to content

Commit

Permalink
Stopped notifications from being sent if the source doesn't download (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kieraneglin authored May 1, 2024
1 parent 3f74f19 commit 8051107
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pinchflat/notifications/source_notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ defmodule Pinchflat.Notifications.SourceNotifications do
end

defp relevant_media_item_count(source) do
pending_media_item_count(source) + downloaded_media_item_count(source)
if source.download_media do
pending_media_item_count(source) + downloaded_media_item_count(source)
else
0
end
end

defp pending_media_item_count(source) do
Expand Down
11 changes: 11 additions & 0 deletions test/pinchflat/notifications/source_notifications_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ defmodule Pinchflat.Notifications.SourceNotificationsTest do
end)
end

test "does not send a notification if the source is set to not download media" do
source = source_fixture(%{download_media: false})

expect(AppriseRunnerMock, :run, 0, fn _, _ -> {:ok, ""} end)

SourceNotifications.wrap_new_media_notification(@apprise_servers, source, fn ->
media_item_fixture(%{source_id: source.id, media_filepath: nil})
media_item_fixture(%{source_id: source.id, media_filepath: "file.mp4"})
end)
end

test "returns the value of the function" do
source = source_fixture()
expect(AppriseRunnerMock, :run, 0, fn _, _ -> {:ok, ""} end)
Expand Down

0 comments on commit 8051107

Please sign in to comment.