Merge branch 'develop' into feature/activitypub
This commit is contained in:
commit
b331cb449a
36 changed files with 139 additions and 115 deletions
|
|
@ -32,7 +32,7 @@ defmodule Pleroma.Stats do
|
|||
domain_count = Enum.count(peers)
|
||||
status_query = from(u in User.local_user_query,
|
||||
select: fragment("sum((?->>'note_count')::int)", u.info))
|
||||
status_count = Repo.one(status_query) |> IO.inspect
|
||||
status_count = Repo.one(status_query)
|
||||
user_count = Repo.aggregate(User.local_user_query, :count, :id)
|
||||
Agent.update(__MODULE__, fn _ ->
|
||||
{peers, %{domain_count: domain_count, status_count: status_count, user_count: user_count}}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ defmodule Pleroma.Web.OStatus.FeedRepresenter do
|
|||
|
||||
h = fn(str) -> [to_charlist(str)] end
|
||||
|
||||
last_activity = List.last(activities)
|
||||
|
||||
entries = activities
|
||||
|> Enum.map(fn(activity) ->
|
||||
{:entry, ActivityRepresenter.to_simple_form(activity, user)}
|
||||
|
|
@ -32,7 +34,15 @@ defmodule Pleroma.Web.OStatus.FeedRepresenter do
|
|||
{:link, [rel: 'salmon', href: h.(OStatus.salmon_path(user))], []},
|
||||
{:link, [rel: 'self', href: h.(OStatus.feed_path(user)), type: 'application/atom+xml'], []},
|
||||
{:author, UserRepresenter.to_simple_form(user)},
|
||||
] ++ entries
|
||||
] ++
|
||||
if last_activity do
|
||||
[{:link, [rel: 'next',
|
||||
href: to_charlist(OStatus.feed_path(user)) ++ '?max_id=' ++ to_charlist(last_activity.id),
|
||||
type: 'application/atom+xml'], []}]
|
||||
else
|
||||
[]
|
||||
end
|
||||
++ entries
|
||||
}]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
|||
end
|
||||
end
|
||||
|
||||
def feed(conn, %{"nickname" => nickname}) do
|
||||
def feed(conn, %{"nickname" => nickname} = params) do
|
||||
user = User.get_cached_by_nickname(nickname)
|
||||
query = from activity in Activity,
|
||||
where: fragment("?->>'actor' = ?", activity.data, ^user.ap_id),
|
||||
|
|
@ -27,6 +27,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
|||
order_by: [desc: :id]
|
||||
|
||||
activities = query
|
||||
|> restrict_max(params)
|
||||
|> Repo.all
|
||||
|
||||
response = user
|
||||
|
|
@ -56,6 +57,11 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
|||
end
|
||||
end
|
||||
|
||||
defp restrict_max(query, %{"max_id" => max_id}) do
|
||||
from activity in query, where: activity.id < ^max_id
|
||||
end
|
||||
defp restrict_max(query, _), do: query
|
||||
|
||||
def salmon_incoming(conn, _) do
|
||||
{:ok, body, _conn} = read_body(conn)
|
||||
{:ok, doc} = decode_or_retry(body)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue