Show users their own posts in timeline.
This commit is contained in:
parent
44586f2967
commit
c974f6544f
@ -151,11 +151,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
end
|
end
|
||||||
defp restrict_tag(query, _), do: query
|
defp restrict_tag(query, _), do: query
|
||||||
|
|
||||||
defp restrict_recipients(query, []), do: query
|
defp restrict_recipients(query, [], user), do: query
|
||||||
defp restrict_recipients(query, recipients) do
|
defp restrict_recipients(query, recipients, nil) do
|
||||||
from activity in query,
|
from activity in query,
|
||||||
where: fragment("? && ?", ^recipients, activity.recipients)
|
where: fragment("? && ?", ^recipients, activity.recipients)
|
||||||
end
|
end
|
||||||
|
defp restrict_recipients(query, recipients, user) do
|
||||||
|
from activity in query,
|
||||||
|
where: fragment("? && ?", ^recipients, activity.recipients),
|
||||||
|
or_where: activity.actor == ^user.ap_id
|
||||||
|
end
|
||||||
|
|
||||||
defp restrict_local(query, %{"local_only" => true}) do
|
defp restrict_local(query, %{"local_only" => true}) do
|
||||||
from activity in query, where: activity.local == true
|
from activity in query, where: activity.local == true
|
||||||
@ -216,7 +221,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
order_by: [fragment("? desc nulls last", activity.id)]
|
order_by: [fragment("? desc nulls last", activity.id)]
|
||||||
|
|
||||||
base_query
|
base_query
|
||||||
|> restrict_recipients(recipients)
|
|> restrict_recipients(recipients, opts["user"])
|
||||||
|> restrict_tag(opts)
|
|> restrict_tag(opts)
|
||||||
|> restrict_since(opts)
|
|> restrict_since(opts)
|
||||||
|> restrict_local(opts)
|
|> restrict_local(opts)
|
||||||
|
@ -27,7 +27,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||||||
def to_for_user_and_mentions(user, mentions, inReplyTo, "public") do
|
def to_for_user_and_mentions(user, mentions, inReplyTo, "public") do
|
||||||
to = ["https://www.w3.org/ns/activitystreams#Public"]
|
to = ["https://www.w3.org/ns/activitystreams#Public"]
|
||||||
|
|
||||||
mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end) ++ [user.ap_id]
|
mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end)
|
||||||
cc = [user.follower_address | mentioned_users]
|
cc = [user.follower_address | mentioned_users]
|
||||||
if inReplyTo do
|
if inReplyTo do
|
||||||
{to, Enum.uniq([inReplyTo.data["actor"] | cc])}
|
{to, Enum.uniq([inReplyTo.data["actor"] | cc])}
|
||||||
@ -47,7 +47,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_for_user_and_mentions(user, mentions, inReplyTo, "direct") do
|
def to_for_user_and_mentions(user, mentions, inReplyTo, "direct") do
|
||||||
mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end) ++ [user.ap_id]
|
mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end)
|
||||||
if inReplyTo do
|
if inReplyTo do
|
||||||
{Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []}
|
{Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []}
|
||||||
else
|
else
|
||||||
|
@ -150,6 +150,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
params = params
|
params = params
|
||||||
|> Map.put("type", ["Create", "Announce"])
|
|> Map.put("type", ["Create", "Announce"])
|
||||||
|> Map.put("blocking_user", user)
|
|> Map.put("blocking_user", user)
|
||||||
|
|> Map.put("user", user)
|
||||||
|
|
||||||
activities = ActivityPub.fetch_activities([user.ap_id | user.following], params)
|
activities = ActivityPub.fetch_activities([user.ap_id | user.following], params)
|
||||||
|> Enum.reverse
|
|> Enum.reverse
|
||||||
|
@ -13,7 +13,10 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_friend_statuses(user, opts \\ %{}) do
|
def fetch_friend_statuses(user, opts \\ %{}) do
|
||||||
opts = Map.put(opts, "blocking_user", user)
|
opts = opts
|
||||||
|
|> Map.put("blocking_user", user)
|
||||||
|
|> Map.put("user", user)
|
||||||
|
|
||||||
ActivityPub.fetch_activities([user.ap_id | user.following], opts)
|
ActivityPub.fetch_activities([user.ap_id | user.following], opts)
|
||||||
|> activities_to_statuses(%{for: user})
|
|> activities_to_statuses(%{for: user})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user