Skip to content

Commit

Permalink
fix(server) - add publish date
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkbln committed Dec 25, 2024
1 parent 50d61d0 commit b790247
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/src/sagas/import.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function* fetchEpisodeDetails({ payload }: Action<string>) {
explicit: get(episode, 'explicit', null),
duration: get(episode, 'duration', null),
cover: get(episode, 'cover', null),
pub_date: get(episode, 'pub_date', null),
transcript: {
language: get(episode, ['transcript', 'language'], null),
rel: get(episode, ['transcript', 'rel'], null),
Expand Down
1 change: 1 addition & 0 deletions client/src/types/episode.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface EpisodeDetailsPayload {
explicit: boolean;
duration: string;
cover: string;
pub_date: string;
transcript: {
language: string;
rel: string;
Expand Down
3 changes: 2 additions & 1 deletion server/lib/publisher/feed_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ defmodule Publisher.FeedParser do
cover: episode.image_url,
chapters: episode.chapters,
transcript: transcript(episode),
contributors: episode.contributors
contributors: episode.contributors,
pub_date: episode.pub_date
}
}}
end
Expand Down
25 changes: 22 additions & 3 deletions server/lib/publisher/wordpress/episode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,31 @@ defmodule Publisher.WordPress.Episode do
Enum.reject(map, fn {_, v} -> is_nil(v) end)
end

defp upload_content(req, post_id, %{"content" => content} = _params)
when not is_nil(content) do
defp upload_content(req, post_id, %{"content" => content, "pub_date" => pub_date} = _params)
when not is_nil(content) and not is_nil(pub_date) do
Logger.info("Episode post #{post_id} content is #{String.length(content)}")
Logger.info("Episode post #{post_id} release date is #{pub_date}")

payload = %{
content: content
content: content,
date: pub_date
}

Req.post(req,
url: "wp/v2/episodes/#{post_id}",
json: payload
)

:ok
end

defp upload_content(req, post_id, %{"content" => content, "pub_date" => pub_date} = _params)
when is_nil(content) and not is_nil(pub_date) do
Logger.info("Episode post has no post content")
Logger.info("Episode post #{post_id} release date is #{pub_date}")

payload = %{
date: pub_date
}

Req.post(req,
Expand Down

0 comments on commit b790247

Please sign in to comment.