diff options
author | lain <lain@soykaf.club> | 2020-08-26 13:17:39 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-08-26 13:17:39 +0200 |
commit | fc42446755d5284a2406633358ab8edfa8c0ab0c (patch) | |
tree | 16924be1f511166b4b1a5d91ce681696ee2a19f1 /lib | |
parent | 49a436ad3e174e1b0b6442f7a777498cc551449c (diff) | |
parent | 797535155051e75227fca611c3486c02c01a98b3 (diff) | |
download | pleroma-fc42446755d5284a2406633358ab8edfa8c0ab0c.tar.gz |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into pleroma-2.1-rc0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 7 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/web_finger/web_finger.ex | 24 |
3 files changed, 22 insertions, 11 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 0b171563b..c1825f810 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -15,6 +15,7 @@ defmodule Pleroma.Notification do alias Pleroma.Repo alias Pleroma.ThreadMute alias Pleroma.User + alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.Push alias Pleroma.Web.Streamer @@ -441,6 +442,7 @@ defmodule Pleroma.Notification do |> Multi.insert(:notification, %Notification{ user_id: user.id, activity: activity, + seen: mark_as_read?(activity, user), type: type_from_activity(activity) }) |> Marker.multi_set_last_read_id(user, "notifications") @@ -634,6 +636,11 @@ defmodule Pleroma.Notification do def skip?(_, _, _), do: false + def mark_as_read?(activity, target_user) do + user = Activity.user_actor(activity) + User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(target_user, activity) + end + def for_user_and_activity(user, activity) do from(n in __MODULE__, where: n.user_id == ^user.id, diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index a8141b28f..5ad2b91c2 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -465,7 +465,7 @@ defmodule Pleroma.Web.CommonAPI do end def thread_muted?(%User{id: user_id}, %{data: %{"context" => context}}) - when is_binary("context") do + when is_binary(context) do ThreadMute.exists?(user_id, context) end diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 71ccf251a..c4051e63e 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -149,6 +149,18 @@ defmodule Pleroma.Web.WebFinger do end end + defp get_address_from_domain(domain, encoded_account) when is_binary(domain) do + case find_lrdd_template(domain) do + {:ok, template} -> + String.replace(template, "{uri}", encoded_account) + + _ -> + "https://#{domain}/.well-known/webfinger?resource=#{encoded_account}" + end + end + + defp get_address_from_domain(_, _), do: nil + @spec finger(String.t()) :: {:ok, map()} | {:error, any()} def finger(account) do account = String.trim_leading(account, "@") @@ -163,16 +175,8 @@ defmodule Pleroma.Web.WebFinger do encoded_account = URI.encode("acct:#{account}") - address = - case find_lrdd_template(domain) do - {:ok, template} -> - String.replace(template, "{uri}", encoded_account) - - _ -> - "https://#{domain}/.well-known/webfinger?resource=#{encoded_account}" - end - - with response <- + with address when is_binary(address) <- get_address_from_domain(domain, encoded_account), + response <- HTTP.get( address, [{"accept", "application/xrd+xml,application/jrd+json"}] |