fix fetching slug #271
1 changed files with 12 additions and 13 deletions
|
@ -41,13 +41,8 @@ defmodule ChiyaWeb.Indie.Micropub do
|
||||||
def find_note(note_url) do
|
def find_note(note_url) do
|
||||||
Logger.info("Looking up note by url #{note_url}")
|
Logger.info("Looking up note by url #{note_url}")
|
||||||
|
|
||||||
slug = Chiya.Notes.Note.note_slug(note_url)
|
case Chiya.Notes.Note.note_slug(note_url) do
|
||||||
|
{:ok, slug} ->
|
||||||
|
|
||||||
if is_nil(slug) do
|
|
||||||
Logger.error("Note with #{note_url} was not found.")
|
|
||||||
{:error, :invalid_request}
|
|
||||||
else
|
|
||||||
Logger.info("Found note with slug #{slug}, fetching note.")
|
Logger.info("Found note with slug #{slug}, fetching note.")
|
||||||
note = Chiya.Notes.get_note_by_slug_preloaded(slug)
|
note = Chiya.Notes.get_note_by_slug_preloaded(slug)
|
||||||
|
|
||||||
|
@ -58,6 +53,10 @@ defmodule ChiyaWeb.Indie.Micropub do
|
||||||
Logger.info("Note found!")
|
Logger.info("Note found!")
|
||||||
{:ok, note}
|
{:ok, note}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Logger.error("Note with #{note_url} was not found.")
|
||||||
|
{:error, :invalid_request}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue