markdown and specs
This commit is contained in:
parent
80d0eb9735
commit
d4f50f2ba9
@ -548,17 +548,20 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
# Domain muting
|
## Domain muting
|
||||||
|
|
||||||
View and update domain mutes.
|
View and update domain mutes.
|
||||||
|
|
||||||
## `GET /api/pleroma/domain_mutes`
|
## `GET /api/pleroma/domain_mutes`
|
||||||
|
|
||||||
### View domains the user has muted.
|
### View domains the user has muted.
|
||||||
|
|
||||||
* Method: `GET`
|
* Method: `GET`
|
||||||
* Authentication: required
|
* Authentication: required
|
||||||
* Params: None
|
* Params: None
|
||||||
* Response: JSON, a list of muted domains.
|
* Response: JSON, a list of muted domains.
|
||||||
* Example Response:
|
* Example Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
"example.com",
|
"example.com",
|
||||||
@ -567,23 +570,29 @@ View and update domain mutes.
|
|||||||
```
|
```
|
||||||
|
|
||||||
## `POST /api/pleroma/domain_mutes`
|
## `POST /api/pleroma/domain_mutes`
|
||||||
|
|
||||||
### Mute domain
|
### Mute domain
|
||||||
|
|
||||||
* Method: `POST`
|
* Method: `POST`
|
||||||
* Authentication: required
|
* Authentication: required
|
||||||
* Params:
|
* Params:
|
||||||
* `domain` - domain to mute
|
* `domain` - domain to mute
|
||||||
* Example Response:
|
* Example Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{}
|
{}
|
||||||
```
|
```
|
||||||
|
|
||||||
## `DELETE /api/pleroma/domain_mutes`
|
## `DELETE /api/pleroma/domain_mutes`
|
||||||
|
|
||||||
### Unmute domain
|
### Unmute domain
|
||||||
|
|
||||||
* Method: `DELETE`
|
* Method: `DELETE`
|
||||||
* Authentication: required
|
* Authentication: required
|
||||||
* Params:
|
* Params:
|
||||||
* `domain` - domain to unmute
|
* `domain` - domain to unmute
|
||||||
* Example Response:
|
* Example Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{}
|
{}
|
||||||
```
|
```
|
@ -979,14 +979,14 @@ defmodule Pleroma.User do
|
|||||||
@spec get_followers_query(User.t()) :: Ecto.Query.t()
|
@spec get_followers_query(User.t()) :: Ecto.Query.t()
|
||||||
def get_followers_query(user), do: get_followers_query(user, nil)
|
def get_followers_query(user), do: get_followers_query(user, nil)
|
||||||
|
|
||||||
@spec get_followers(User.t(), pos_integer() | nil) :: [User.t()]
|
@spec get_followers(t(), pos_integer() | nil) :: [t()]
|
||||||
def get_followers(user, page \\ nil) do
|
def get_followers(user, page \\ nil) do
|
||||||
user
|
user
|
||||||
|> get_followers_query(page)
|
|> get_followers_query(page)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_external_followers(User.t(), pos_integer() | nil) :: [User.t()]
|
@spec get_external_followers(t(), pos_integer() | nil) :: [t()]
|
||||||
def get_external_followers(user, page \\ nil) do
|
def get_external_followers(user, page \\ nil) do
|
||||||
user
|
user
|
||||||
|> get_followers_query(page)
|
|> get_followers_query(page)
|
||||||
@ -1001,7 +1001,7 @@ defmodule Pleroma.User do
|
|||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_friends_query(User.t(), pos_integer() | nil) :: Ecto.Query.t()
|
@spec get_friends_query(t(), pos_integer() | nil) :: Ecto.Query.t()
|
||||||
def get_friends_query(%User{} = user, nil) do
|
def get_friends_query(%User{} = user, nil) do
|
||||||
User.Query.build(%{friends: user, deactivated: false})
|
User.Query.build(%{friends: user, deactivated: false})
|
||||||
end
|
end
|
||||||
@ -1289,19 +1289,19 @@ defmodule Pleroma.User do
|
|||||||
unblock(blocker, get_cached_by_ap_id(ap_id))
|
unblock(blocker, get_cached_by_ap_id(ap_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec mutes?(User.t() | nil, User.t()) :: boolean()
|
@spec mutes?(t() | nil, t()) :: boolean()
|
||||||
def mutes?(nil, _), do: false
|
def mutes?(nil, _), do: false
|
||||||
|
|
||||||
def mutes?(%User{} = user, %User{} = target) do
|
def mutes?(%User{} = user, %User{} = target) do
|
||||||
mutes_user?(user, target) || mutes_domain?(user, target)
|
mutes_user?(user, target) || mutes_domain?(user, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec mutes_user?(User.t(), User.t()) :: boolean()
|
@spec mutes_user?(t(), t()) :: boolean()
|
||||||
def mutes_user?(%User{} = user, %User{} = target) do
|
def mutes_user?(%User{} = user, %User{} = target) do
|
||||||
UserRelationship.mute_exists?(user, target)
|
UserRelationship.mute_exists?(user, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec mutes_domain?(User.t() | nil, User.t()) :: boolean()
|
@spec mutes_domain?(t() | nil, t()) :: boolean()
|
||||||
def mutes_domain?(nil, _), do: false
|
def mutes_domain?(nil, _), do: false
|
||||||
|
|
||||||
def mutes_domain?(%User{} = user, %User{} = target) do
|
def mutes_domain?(%User{} = user, %User{} = target) do
|
||||||
@ -2147,12 +2147,12 @@ defmodule Pleroma.User do
|
|||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec mute_domain(User.t(), String.t()) :: {:ok, User.t()}
|
@spec mute_domain(t(), String.t()) :: {:ok, t()}
|
||||||
def mute_domain(%User{} = user, muted_domain) do
|
def mute_domain(%User{} = user, muted_domain) do
|
||||||
set_domain_mutes(user, Enum.uniq([muted_domain | user.domain_mutes]))
|
set_domain_mutes(user, Enum.uniq([muted_domain | user.domain_mutes]))
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec unmute_domain(User.t(), String.t()) :: {:ok, User.t()}
|
@spec unmute_domain(t(), String.t()) :: {:ok, t()}
|
||||||
def unmute_domain(user, muted_domain) do
|
def unmute_domain(user, muted_domain) do
|
||||||
set_domain_mutes(user, List.delete(user.domain_mutes, muted_domain))
|
set_domain_mutes(user, List.delete(user.domain_mutes, muted_domain))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user