From 43c40273050c6e798b15c328105c034250ec924c Mon Sep 17 00:00:00 2001 From: Jerod Santo Date: Wed, 22 Jan 2025 13:03:17 -0600 Subject: [PATCH] Only socialize Changelog pods --- lib/changelog/oban_workers/social_poster.ex | 10 ++++++---- test/changelog/notifier_test.exs | 13 ++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/changelog/oban_workers/social_poster.ex b/lib/changelog/oban_workers/social_poster.ex index 067c57a51d..13692b8f2c 100644 --- a/lib/changelog/oban_workers/social_poster.ex +++ b/lib/changelog/oban_workers/social_poster.ex @@ -10,10 +10,12 @@ defmodule Changelog.ObanWorkers.SocialPoster do def perform(%Oban.Job{args: %{"episode_id" => episode_id}}) do episode = Episode |> Repo.get(episode_id) |> Episode.preload_all() - post_bsky_new_episode_message(episode) - post_social_new_episode_message(episode) - post_slack_new_episode_message(episode) - post_zulip_new_episode_message(episode) + if Changelog.Podcast.is_a_changelog_pod(episode.podcast) do + post_bsky_new_episode_message(episode) + post_social_new_episode_message(episode) + post_slack_new_episode_message(episode) + post_zulip_new_episode_message(episode) + end :ok end diff --git a/test/changelog/notifier_test.exs b/test/changelog/notifier_test.exs index ede3077364..2793aacf63 100644 --- a/test/changelog/notifier_test.exs +++ b/test/changelog/notifier_test.exs @@ -191,11 +191,12 @@ defmodule Changelog.NotifierTest do {Social, [], [post: fn _ -> true end]}, {Zulip, [], [post: fn _ -> true end]} ]) do - :ok + podcast = insert(:podcast, slug: "news") + episode = insert(:published_episode, podcast: podcast) + {:ok, episode: episode} end - test "when episode has no guests" do - episode = insert(:published_episode) + test "when episode has no guests", %{episode: episode} do item = episode |> episode_news_item() |> insert() Notifier.notify(item) @@ -209,10 +210,9 @@ defmodule Changelog.NotifierTest do assert called(Zulip.post(:_)) end - test "when episode has guests but none of them have 'thanks' set" do + test "when episode has guests but none of them have 'thanks' set", %{episode: episode} do g1 = insert(:person) g2 = insert(:person) - episode = insert(:published_episode) insert(:episode_guest, episode: episode, person: g1, thanks: false) insert(:episode_guest, episode: episode, person: g2, thanks: false) item = episode |> episode_news_item() |> insert() @@ -228,11 +228,10 @@ defmodule Changelog.NotifierTest do assert called(Zulip.post(:_)) end - test "when episode has guests and some of them have 'thanks' set" do + test "when episode has guests and some of them have 'thanks' set", %{episode: episode} do g1 = insert(:person) g2 = insert(:person) g3 = insert(:person) - episode = insert(:published_episode) insert(:episode_guest, episode: episode, person: g1, thanks: false) eg1 = insert(:episode_guest, episode: episode, person: g2, thanks: true) eg2 = insert(:episode_guest, episode: episode, person: g3, thanks: true)