markdown and specs

This commit is contained in:
Alexander Strizhakov 2020-05-19 09:36:20 +03:00
parent 80d0eb9735
commit d4f50f2ba9
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
2 changed files with 19 additions and 10 deletions

View File

@ -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.
## `GET /api/pleroma/domain_mutes`
### View domains the user has muted.
* Method: `GET`
* Authentication: required
* Params: None
* Response: JSON, a list of muted domains.
* Example Response:
```json
[
"example.com",
@ -567,23 +570,29 @@ View and update domain mutes.
```
## `POST /api/pleroma/domain_mutes`
### Mute domain
* Method: `POST`
* Authentication: required
* Params:
* `domain` - domain to mute
* Example Response:
```json
{}
```
## `DELETE /api/pleroma/domain_mutes`
### Unmute domain
* Method: `DELETE`
* Authentication: required
* Params:
* `domain` - domain to unmute
* Example Response:
```json
{}
```

View File

@ -979,14 +979,14 @@ defmodule Pleroma.User do
@spec get_followers_query(User.t()) :: Ecto.Query.t()
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
user
|> get_followers_query(page)
|> Repo.all()
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
user
|> get_followers_query(page)
@ -1001,7 +1001,7 @@ defmodule Pleroma.User do
|> Repo.all()
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
User.Query.build(%{friends: user, deactivated: false})
end
@ -1289,19 +1289,19 @@ defmodule Pleroma.User do
unblock(blocker, get_cached_by_ap_id(ap_id))
end
@spec mutes?(User.t() | nil, User.t()) :: boolean()
@spec mutes?(t() | nil, t()) :: boolean()
def mutes?(nil, _), do: false
def mutes?(%User{} = user, %User{} = target) do
mutes_user?(user, target) || mutes_domain?(user, target)
end
@spec mutes_user?(User.t(), User.t()) :: boolean()
@spec mutes_user?(t(), t()) :: boolean()
def mutes_user?(%User{} = user, %User{} = target) do
UserRelationship.mute_exists?(user, target)
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?(%User{} = user, %User{} = target) do
@ -2147,12 +2147,12 @@ defmodule Pleroma.User do
|> update_and_set_cache()
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
set_domain_mutes(user, Enum.uniq([muted_domain | user.domain_mutes]))
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
set_domain_mutes(user, List.delete(user.domain_mutes, muted_domain))
end