Skip to content

Commit

Permalink
Only socialize Changelog pods
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Jan 22, 2025
1 parent 36f4671 commit 43c4027
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 6 additions & 4 deletions lib/changelog/oban_workers/social_poster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions test/changelog/notifier_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 43c4027

Please sign in to comment.