Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
5637d163
Commit
5637d163
authored
Nov 30, 2017
by
lain
Browse files
MastodonAPI: Add proper user count.
parent
9d1c0ec1
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
5637d163
...
...
@@ -329,4 +329,9 @@ def blocks?(user, %{ap_id: ap_id}) do
Enum
.
member?
(
blocks
,
ap_id
)
end
def
local_user_query
()
do
from
u
in
User
,
where:
u
.
local
==
true
end
end
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
View file @
5637d163
...
...
@@ -93,6 +93,7 @@ def user(conn, %{"id" => id}) do
@instance
Application
.
get_env
(
:pleroma
,
:instance
)
def
masto_instance
(
conn
,
_params
)
do
user_count
=
Repo
.
aggregate
(
User
.
local_user_query
,
:count
,
:id
)
response
=
%{
uri:
Web
.
base_url
,
title:
Keyword
.
get
(
@instance
,
:name
),
...
...
@@ -103,8 +104,8 @@ def masto_instance(conn, _params) do
streaming_api:
String
.
replace
(
Web
.
base_url
,
[
"http"
,
"https"
],
"wss"
)
},
stats:
%{
user_count:
1
,
status_count:
2
,
user_count:
user_count
,
domain_count:
3
},
max_toot_chars:
Keyword
.
get
(
@instance
,
:limit
)
...
...
test/web/mastodon_api/mastodon_api_controller_test.exs
View file @
5637d163
...
...
@@ -573,4 +573,19 @@ test "updates the user's banner" do
assert
user
[
"header"
]
!=
"https://placehold.it/700x335"
end
end
test
"get instance information"
do
insert
(
:user
,
%{
local:
true
})
user
=
insert
(
:user
,
%{
local:
true
})
insert
(
:user
,
%{
local:
false
})
{
:ok
,
_
}
=
TwitterAPI
.
create_status
(
user
,
%{
"status"
=>
"cofe"
})
conn
=
conn
|>
get
(
"/api/v1/instance"
)
assert
result
=
json_response
(
conn
,
200
)
assert
result
[
"stats"
][
"user_count"
]
==
2
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment