Fix friendica recognition

Closes #107
pull/1/head
Inex Code 2021-09-18 19:21:16 +03:00
rodzic 7bb8bd0a8a
commit aacc8574d8
2 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -18,7 +18,7 @@ defmodule Backend.Crawler.ApiCrawler do
# {domain, type} e.g. {"gab.com", "reject"} # {domain, type} e.g. {"gab.com", "reject"}
@type federation_restriction :: {String.t(), String.t()} @type federation_restriction :: {String.t(), String.t()}
@type instance_type :: :mastodon | :pleroma | :gab | :misskey | :gnusocial | :smithereen @type instance_type :: :mastodon | :pleroma | :gab | :misskey | :gnusocial | :smithereen | :friendica
defstruct [ defstruct [
:version, :version,

Wyświetl plik

@ -12,8 +12,14 @@ defmodule Backend.Crawler.Crawlers.Mastodon do
@impl ApiCrawler @impl ApiCrawler
def is_instance_type?(domain, result) do def is_instance_type?(domain, result) do
# We might already know that this is a Pleroma instance from nodeinfo # We might already know that this is a Pleroma instance from nodeinfo
if result != nil and (Map.get(result, :instance_type) == :pleroma or Map.get(result, :instance_type) == :smithereen) do if result != nil do
true cond do
Map.get(result, :instance_type) == :pleroma -> true
Map.get(result, :instance_type) == :smithereen -> true
Map.get(result, :instance_type) == :mastodon -> true
Map.get(result, :instance_type) == :friendica -> false
true -> false
end
else else
case get_and_decode("https://#{domain}/api/v1/instance") do case get_and_decode("https://#{domain}/api/v1/instance") do
{:ok, %{"title" => _title}} -> true {:ok, %{"title" => _title}} -> true