end
def fetch_friend_statuses(user, opts \\ %{}) do
+ opts = Map.put(opts, "blocking_user", user)
ActivityPub.fetch_activities([user.ap_id | user.following], opts)
|> activities_to_statuses(%{for: user})
end
def fetch_public_statuses(user, opts \\ %{}) do
opts = Map.put(opts, "local_only", true)
+ opts = Map.put(opts, "blocking_user", user)
ActivityPub.fetch_public_activities(opts)
|> activities_to_statuses(%{for: user})
end
def fetch_public_and_external_statuses(user, opts \\ %{}) do
+ opts = Map.put(opts, "blocking_user", user)
ActivityPub.fetch_public_activities(opts)
|> activities_to_statuses(%{for: user})
end
def fetch_conversation(user, id) do
with context when is_binary(context) <- conversation_id_to_context(id),
- activities <- ActivityPub.fetch_activities_for_context(context),
+ activities <- ActivityPub.fetch_activities_for_context(context, %{"blocking_user" => user}),
statuses <- activities |> activities_to_statuses(%{for: user})
do
statuses
end
end
+ def block(%User{} = blocker, params) do
+ with {:ok, %User{} = blocked} <- get_user(params),
+ {:ok, blocker} <- User.block(blocker, blocked)
+ do
+ {:ok, blocker, blocked}
+ else
+ err -> err
+ end
+ end
+
+ def unblock(%User{} = blocker, params) do
+ with {:ok, %User{} = blocked} <- get_user(params),
+ {:ok, blocker} <- User.unblock(blocker, blocked)
+ do
+ {:ok, blocker, blocked}
+ else
+ err -> err
+ end
+ end
+
def repeat(%User{} = user, ap_id_or_id) do
with {:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(ap_id_or_id, user),
%Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id),
where: fragment("?->>'type' = 'Create'", a.data),
where: fragment("to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)", a.data, ^query),
limit: ^limit,
- offset: ^offset
+ offset: ^offset,
+ order_by: [desc: :inserted_at] # this one isn't indexed so psql won't take the wrong index.
activities = Repo.all(q)
activities_to_statuses(activities, %{for: user})