Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into pleroma-2.1-rc0

This commit is contained in:
lain 2020-08-26 13:17:39 +02:00
commit fc42446755
9 changed files with 68 additions and 25 deletions

View file

@ -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,

View file

@ -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

View file

@ -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"}]