Skip to content
GitLab
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
c6b9b777
Commit
c6b9b777
authored
Nov 03, 2017
by
lain
Browse files
MastoAPI: Add list of blocked users.
parent
5bf92e50
Pipeline
#21
passed with stage
in 1 minute and 52 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
View file @
c6b9b777
...
...
@@ -335,6 +335,15 @@ def unblock(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do
end
end
# TODO: Use proper query
def
blocks
(%{
assigns:
%{
user:
user
}}
=
conn
,
_
)
do
with
blocked_users
<-
user
.
info
[
"blocks"
]
||
[],
accounts
<-
Enum
.
map
(
blocked_users
,
fn
(
ap_id
)
->
User
.
get_cached_by_ap_id
(
ap_id
)
end
)
do
res
=
AccountView
.
render
(
"accounts.json"
,
users:
accounts
,
for:
user
,
as:
:user
)
json
(
conn
,
res
)
end
end
def
search
(%{
assigns:
%{
user:
user
}}
=
conn
,
%{
"q"
=>
query
}
=
params
)
do
accounts
=
User
.
search
(
query
,
params
[
"resolve"
]
==
"true"
)
...
...
lib/pleroma/web/router.ex
View file @
c6b9b777
...
...
@@ -65,7 +65,8 @@ def user_fetcher(username) do
post
"/follows"
,
MastodonAPIController
,
:follow
get
"/blocks"
,
MastodonAPIController
,
:empty_array
get
"/blocks"
,
MastodonAPIController
,
:blocks
get
"/domain_blocks"
,
MastodonAPIController
,
:empty_array
get
"/follow_requests"
,
MastodonAPIController
,
:empty_array
get
"/mutes"
,
MastodonAPIController
,
:empty_array
...
...
test/web/mastodon_api/mastodon_api_controller_test.exs
View file @
c6b9b777
...
...
@@ -309,6 +309,20 @@ test "blocking / unblocking a user", %{conn: conn} do
assert
%{
"id"
=>
id
,
"blocking"
=>
false
}
=
json_response
(
conn
,
200
)
end
test
"getting a list of blocks"
,
%{
conn:
conn
}
do
user
=
insert
(
:user
)
other_user
=
insert
(
:user
)
{
:ok
,
user
}
=
User
.
block
(
user
,
other_user
)
conn
=
conn
|>
assign
(
:user
,
user
)
|>
get
(
"/api/v1/blocks"
)
other_user_id
=
other_user
.
id
assert
[%{
"id"
=>
^
other_user_id
}]
=
json_response
(
conn
,
200
)
end
test
"unimplemented mute endpoints"
do
user
=
insert
(
:user
)
other_user
=
insert
(
:user
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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