add like and repost as supported types

This commit is contained in:
Inhji 2023-08-16 22:54:57 +02:00
parent f1c333acec
commit 0267ae07d8
2 changed files with 16 additions and 11 deletions

View file

@ -25,6 +25,14 @@ defmodule ChiyaWeb.Indie.MicropubHandler do
%{ %{
"type" => "bookmark", "type" => "bookmark",
"name" => "Bookmark" "name" => "Bookmark"
},
%{
"type" => "like",
"name" => "Like"
},
%{
"type" => "repost",
"name" => "Repost"
} }
] ]

View file

@ -1,17 +1,14 @@
defmodule ChiyaWeb.Indie.Properties do defmodule ChiyaWeb.Indie.Properties do
def get_post_type(properties) do def get_post_type(properties) do
cond do cond do
Map.has_key?(properties, "like-of") -> Map.has_key?(properties, "like-of") -> {:ok, :like}
{:ok, :like} Map.has_key?(properties, "bookmark-of") -> {:ok, :bookmark}
Map.has_key?(properties, "content") -> {:ok, :note}
Map.has_key?(properties, "bookmark-of") -> Map.has_key?(properties, "repost-of") -> {:ok, :repost}
{:ok, :bookmark} Map.has_key?(properties, "read-of") -> {:ok, :read}
Map.has_key?(properties, "watch-of") -> {:ok, :watch}
Map.has_key?(properties, "content") -> Map.has_key?(properties, "listen-of") -> {:ok, :listen}
{:ok, :note} true -> {:error, :unsupported_posttype}
true ->
{:error, :unsupported_posttype}
end end
end end