Authorize or reject a follow request
parent
49e56fe52d
commit
68e47daf4b
|
@ -36,7 +36,6 @@ All contributions are welcome!
|
|||
* OAuth2 authentication
|
||||
- Register client for token-access
|
||||
- Token authentication for API usage
|
||||
* Authorizing or rejecting follow requests
|
||||
* Support arrays as parameter type
|
||||
* Uploading media attachment
|
||||
* Getting who reblogged/favourited a status
|
||||
|
|
|
@ -115,6 +115,30 @@ defmodule Hunter do
|
|||
@spec mutes(Hunter.Client.t) :: [Hunter.Account.t]
|
||||
defdelegate mutes(conn), to: Hunter.Account
|
||||
|
||||
@doc """
|
||||
Accepts a follow request
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - follow request id
|
||||
|
||||
"""
|
||||
@spec accept_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
|
||||
defdelegate accept_follow_request(conn, id), to: Hunter.Account
|
||||
|
||||
@doc """
|
||||
Rejects a follow request
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - follow request id
|
||||
|
||||
"""
|
||||
@spec reject_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
|
||||
defdelegate reject_follow_request(conn, id), to: Hunter.Account
|
||||
|
||||
## Application
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -181,4 +181,32 @@ defmodule Hunter.Account do
|
|||
def mutes(conn) do
|
||||
@hunter_api.mutes(conn)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Accepts a follow request
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - follow request id
|
||||
|
||||
"""
|
||||
@spec accept_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
|
||||
def accept_follow_request(conn, id) do
|
||||
@hunter_api.follow_request_action(conn, id, :authorize)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Rejects a follow request
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - follow request id
|
||||
|
||||
"""
|
||||
@spec reject_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
|
||||
def reject_follow_request(conn, id ) do
|
||||
@hunter_api.follow_request_action(conn, id, :reject)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,6 +105,23 @@ defmodule Hunter.Api do
|
|||
"""
|
||||
@callback mutes(conn :: Hunter.Client.t) :: [Hunter.Account.t]
|
||||
|
||||
@doc """
|
||||
Accepts or Rejects a follow request
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - follow request id
|
||||
* `action` - action to take
|
||||
|
||||
## Actions
|
||||
|
||||
* `:authorize` - authorize a follow request
|
||||
* `:reject` - reject a follow request
|
||||
|
||||
"""
|
||||
@callback follow_request_action(conn :: Hunter.Client.t, id :: non_neg_integer, action :: atom) :: boolean
|
||||
|
||||
## Application
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -52,6 +52,13 @@ defmodule Hunter.Api.HTTPClient do
|
|||
Poison.decode!(body, as: [%Hunter.Account{}])
|
||||
end
|
||||
|
||||
def follow_request_action(%Hunter.Client{base_url: base_url} = conn, id, action) when action in [:authorize, :reject] do
|
||||
payload = Poison.encode!(%{id: id})
|
||||
|
||||
%HTTPoison.Response{status_code: 200} = HTTPoison.post!(base_url <> "/api/v1/follow_requests/#{action}", payload, [{"Content-Type", "application/json"} | get_headers(conn)])
|
||||
true
|
||||
end
|
||||
|
||||
def create_app(%Hunter.Client{base_url: base_url} = conn, name, redirect_uri, scopes, website) do
|
||||
payload = Poison.encode!(%{client_name: name, redirect_uris: redirect_uri, scopes: scopes, website: website})
|
||||
|
||||
|
|
Loading…
Reference in New Issue