Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33102900
domain_block_controller.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
domain_block_controller.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.MastodonAPI.DomainBlockController
do
use
Pleroma.Web
,
:controller
alias
Pleroma.User
alias
Pleroma.Web.Plugs.OAuthScopesPlug
plug
(
Pleroma.Web.ApiSpec.CastAndValidate
,
replace_params
:
false
)
defdelegate
open_api_operation
(
action
),
to
:
Pleroma.Web.ApiSpec.DomainBlockOperation
plug
(
OAuthScopesPlug
,
%{
scopes
:
[
"follow"
,
"read:blocks"
]}
when
action
==
:index
)
plug
(
OAuthScopesPlug
,
%{
scopes
:
[
"follow"
,
"write:blocks"
]}
when
action
!=
:index
)
@doc
"GET /api/v1/domain_blocks"
def
index
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
_
)
do
json
(
conn
,
Map
.
get
(
user
,
:domain_blocks
,
[]))
end
@doc
"POST /api/v1/domain_blocks"
def
create
(
%{
assigns
:
%{
user
:
blocker
},
private
:
%{
open_api_spex
:
%{
body_params
:
%{
domain
:
domain
}}}}
=
conn
,
_params
)
do
User
.
block_domain
(
blocker
,
domain
)
json
(
conn
,
%{})
end
def
create
(%{
assigns
:
%{
user
:
blocker
}}
=
conn
,
%{
"domain"
=>
domain
})
do
User
.
block_domain
(
blocker
,
domain
)
json
(
conn
,
%{})
end
@doc
"DELETE /api/v1/domain_blocks"
def
delete
(
%{
assigns
:
%{
user
:
blocker
},
private
:
%{
open_api_spex
:
%{
body_params
:
%{
domain
:
domain
}}}}
=
conn
,
_params
)
do
User
.
unblock_domain
(
blocker
,
domain
)
json
(
conn
,
%{})
end
def
delete
(%{
assigns
:
%{
user
:
blocker
}}
=
conn
,
%{
"domain"
=>
domain
})
do
User
.
unblock_domain
(
blocker
,
domain
)
json
(
conn
,
%{})
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Tue, Jan 20, 1:12 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
901279
Default Alt Text
domain_block_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment