Compare commits
2 commits
28bf902599
...
2bb801b6d0
Author | SHA1 | Date | |
---|---|---|---|
2bb801b6d0 | |||
ec282e207f |
5 changed files with 29 additions and 15 deletions
|
@ -401,6 +401,10 @@ enbas show --type status --status-id 01J1Z9PT0243JT9QNQ5W96Z8CA
|
||||||
```
|
```
|
||||||
enbas create --type status --content-type markdown --visibility private --from-file status.md
|
enbas create --type status --content-type markdown --visibility private --from-file status.md
|
||||||
```
|
```
|
||||||
|
- Reply to another status.
|
||||||
|
```
|
||||||
|
enbas create --type status --in-reply-to 01J2A86E3M7WWH37H1QENT7CSH --content "@bernie thanks for this! Looking forward to trying this out."
|
||||||
|
```
|
||||||
- Create a status with a poll
|
- Create a status with a poll
|
||||||
```
|
```
|
||||||
enbas create \
|
enbas create \
|
||||||
|
@ -428,6 +432,7 @@ enbas show --type status --status-id 01J1Z9PT0243JT9QNQ5W96Z8CA
|
||||||
| `enable-likes` | boolean | false | The status can be liked (favourtied). | true |
|
| `enable-likes` | boolean | false | The status can be liked (favourtied). | true |
|
||||||
| `enable-replies` | boolean | false | The status can be replied to. | true |
|
| `enable-replies` | boolean | false | The status can be replied to. | true |
|
||||||
| `from-file` | string | false | The path to the file where to read the contents of the status from. | |
|
| `from-file` | string | false | The path to the file where to read the contents of the status from. | |
|
||||||
|
| `in-reply-to` | string | false | The ID of the status that you want to reply to. | |
|
||||||
| `language` | string | false | The ISO 639 language code that the status is written in.<br>If this is not specified then the default language from your posting preferences will be used. | |
|
| `language` | string | false | The ISO 639 language code that the status is written in.<br>If this is not specified then the default language from your posting preferences will be used. | |
|
||||||
| `sensitive` | string | false | The status should be marked as sensitive.<br>If this is not specified then the default sensitivity from your posting preferences will be used. | |
|
| `sensitive` | string | false | The status should be marked as sensitive.<br>If this is not specified then the default sensitivity from your posting preferences will be used. | |
|
||||||
| `spoiler-text` | string | false | The text to display as the status' warning or subject. | |
|
| `spoiler-text` | string | false | The text to display as the status' warning or subject. | |
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
listPath string = "/api/v1/lists"
|
baseListPath string = "/api/v1/lists"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Client) GetAllLists() ([]model.List, error) {
|
func (g *Client) GetAllLists() ([]model.List, error) {
|
||||||
url := g.Authentication.Instance + listPath
|
url := g.Authentication.Instance + baseListPath
|
||||||
|
|
||||||
var lists []model.List
|
var lists []model.List
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ func (g *Client) GetAllLists() ([]model.List, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) GetList(listID string) (model.List, error) {
|
func (g *Client) GetList(listID string) (model.List, error) {
|
||||||
url := g.Authentication.Instance + listPath + "/" + listID
|
url := g.Authentication.Instance + baseListPath + "/" + listID
|
||||||
|
|
||||||
var list model.List
|
var list model.List
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ func (g *Client) CreateList(form CreateListForm) (model.List, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestBody := bytes.NewBuffer(data)
|
requestBody := bytes.NewBuffer(data)
|
||||||
url := g.Authentication.Instance + "/api/v1/lists"
|
url := g.Authentication.Instance + baseListPath
|
||||||
|
|
||||||
var list model.List
|
var list model.List
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ func (g *Client) UpdateList(listToUpdate model.List) (model.List, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestBody := bytes.NewBuffer(data)
|
requestBody := bytes.NewBuffer(data)
|
||||||
url := g.Authentication.Instance + listPath + "/" + listToUpdate.ID
|
url := g.Authentication.Instance + baseListPath + "/" + listToUpdate.ID
|
||||||
|
|
||||||
var updatedList model.List
|
var updatedList model.List
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ func (g *Client) UpdateList(listToUpdate model.List) (model.List, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) DeleteList(listID string) error {
|
func (g *Client) DeleteList(listID string) error {
|
||||||
url := g.Authentication.Instance + "/api/v1/lists/" + listID
|
url := g.Authentication.Instance + baseListPath + "/" + listID
|
||||||
|
|
||||||
return g.sendRequest(http.MethodDelete, url, nil, nil)
|
return g.sendRequest(http.MethodDelete, url, nil, nil)
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func (g *Client) AddAccountsToList(listID string, accountIDs []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestBody := bytes.NewBuffer(data)
|
requestBody := bytes.NewBuffer(data)
|
||||||
url := g.Authentication.Instance + listPath + "/" + listID + "/accounts"
|
url := g.Authentication.Instance + baseListPath + "/" + listID + "/accounts"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil {
|
if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -146,7 +146,7 @@ func (g *Client) RemoveAccountsFromList(listID string, accountIDs []string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
requestBody := bytes.NewBuffer(data)
|
requestBody := bytes.NewBuffer(data)
|
||||||
url := g.Authentication.Instance + listPath + "/" + listID + "/accounts"
|
url := g.Authentication.Instance + baseListPath + "/" + listID + "/accounts"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodDelete, url, requestBody, nil); err != nil {
|
if err := g.sendRequest(http.MethodDelete, url, requestBody, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -159,7 +159,7 @@ func (g *Client) RemoveAccountsFromList(listID string, accountIDs []string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) GetAccountsFromList(listID string, limit int) ([]model.Account, error) {
|
func (g *Client) GetAccountsFromList(listID string, limit int) ([]model.Account, error) {
|
||||||
path := fmt.Sprintf("%s/%s/accounts?limit=%d", listPath, listID, limit)
|
path := fmt.Sprintf("%s/%s/accounts?limit=%d", baseListPath, listID, limit)
|
||||||
url := g.Authentication.Instance + path
|
url := g.Authentication.Instance + path
|
||||||
|
|
||||||
var accounts []model.Account
|
var accounts []model.Account
|
||||||
|
|
|
@ -13,8 +13,12 @@ import (
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
baseStatusesPath string = "/api/v1/statuses"
|
||||||
|
)
|
||||||
|
|
||||||
func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
||||||
path := "/api/v1/statuses/" + statusID
|
path := baseStatusesPath + "/" + statusID
|
||||||
url := g.Authentication.Instance + path
|
url := g.Authentication.Instance + path
|
||||||
|
|
||||||
var status model.Status
|
var status model.Status
|
||||||
|
@ -31,6 +35,7 @@ func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
||||||
|
|
||||||
type CreateStatusForm struct {
|
type CreateStatusForm struct {
|
||||||
Content string `json:"status"`
|
Content string `json:"status"`
|
||||||
|
InReplyTo string `json:"in_reply_to_id"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
SpoilerText string `json:"spoiler_text"`
|
SpoilerText string `json:"spoiler_text"`
|
||||||
Boostable bool `json:"boostable"`
|
Boostable bool `json:"boostable"`
|
||||||
|
@ -57,7 +62,7 @@ func (g *Client) CreateStatus(form CreateStatusForm) (model.Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestBody := bytes.NewBuffer(data)
|
requestBody := bytes.NewBuffer(data)
|
||||||
url := g.Authentication.Instance + "/api/v1/statuses"
|
url := g.Authentication.Instance + baseStatusesPath
|
||||||
|
|
||||||
var status model.Status
|
var status model.Status
|
||||||
|
|
||||||
|
@ -119,7 +124,7 @@ func (g *Client) RemoveStatusFromBookmarks(statusID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) LikeStatus(statusID string) error {
|
func (g *Client) LikeStatus(statusID string) error {
|
||||||
url := g.Authentication.Instance + "/api/v1/statuses/" + statusID + "/favourite"
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/favourite"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -132,7 +137,7 @@ func (g *Client) LikeStatus(statusID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) UnlikeStatus(statusID string) error {
|
func (g *Client) UnlikeStatus(statusID string) error {
|
||||||
url := g.Authentication.Instance + "/api/v1/statuses/" + statusID + "/unfavourite"
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/unfavourite"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -163,7 +168,7 @@ func (g *Client) GetLikedStatuses(limit int, resourceName string) (model.StatusL
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) ReblogStatus(statusID string) error {
|
func (g *Client) ReblogStatus(statusID string) error {
|
||||||
url := g.Authentication.Instance + "/api/v1/statuses/" + statusID + "/reblog"
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/reblog"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -176,7 +181,7 @@ func (g *Client) ReblogStatus(statusID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) UnreblogStatus(statusID string) error {
|
func (g *Client) UnreblogStatus(statusID string) error {
|
||||||
url := g.Authentication.Instance + "/api/v1/statuses/" + statusID + "/unreblog"
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/unreblog"
|
||||||
|
|
||||||
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
|
|
@ -32,6 +32,7 @@ type CreateExecutor struct {
|
||||||
content string
|
content string
|
||||||
contentType string
|
contentType string
|
||||||
fromFile string
|
fromFile string
|
||||||
|
inReplyTo string
|
||||||
language string
|
language string
|
||||||
resourceType string
|
resourceType string
|
||||||
listTitle string
|
listTitle string
|
||||||
|
@ -58,6 +59,7 @@ func NewCreateExecutor(printer *printer.Printer, config *config.Config, name, su
|
||||||
createExe.StringVar(&createExe.contentType, flagContentType, "plain", "The type that the contents should be parsed from (valid values are plain and markdown)")
|
createExe.StringVar(&createExe.contentType, flagContentType, "plain", "The type that the contents should be parsed from (valid values are plain and markdown)")
|
||||||
createExe.BoolVar(&createExe.federated, flagEnableFederation, true, "Specify if the status can be federated beyond the local timelines")
|
createExe.BoolVar(&createExe.federated, flagEnableFederation, true, "Specify if the status can be federated beyond the local timelines")
|
||||||
createExe.StringVar(&createExe.fromFile, flagFromFile, "", "The file path where to read the contents from")
|
createExe.StringVar(&createExe.fromFile, flagFromFile, "", "The file path where to read the contents from")
|
||||||
|
createExe.StringVar(&createExe.inReplyTo, flagInReplyTo, "", "The ID of the status that you want to reply to")
|
||||||
createExe.StringVar(&createExe.language, flagLanguage, "", "The ISO 639 language code for this status")
|
createExe.StringVar(&createExe.language, flagLanguage, "", "The ISO 639 language code for this status")
|
||||||
createExe.BoolVar(&createExe.likeable, flagEnableLikes, true, "Specify if the status can be liked/favourited")
|
createExe.BoolVar(&createExe.likeable, flagEnableLikes, true, "Specify if the status can be liked/favourited")
|
||||||
createExe.BoolVar(&createExe.replyable, flagEnableReplies, true, "Specify if the status can be replied to")
|
createExe.BoolVar(&createExe.replyable, flagEnableReplies, true, "Specify if the status can be replied to")
|
||||||
|
@ -204,6 +206,7 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
SpoilerText: c.spoilerText,
|
SpoilerText: c.spoilerText,
|
||||||
Boostable: c.boostable,
|
Boostable: c.boostable,
|
||||||
Federated: c.federated,
|
Federated: c.federated,
|
||||||
|
InReplyTo: c.inReplyTo,
|
||||||
Likeable: c.likeable,
|
Likeable: c.likeable,
|
||||||
Replyable: c.replyable,
|
Replyable: c.replyable,
|
||||||
Sensitive: sensitive,
|
Sensitive: sensitive,
|
||||||
|
|
|
@ -25,6 +25,7 @@ const (
|
||||||
flagFrom = "from"
|
flagFrom = "from"
|
||||||
flagFromFile = "from-file"
|
flagFromFile = "from-file"
|
||||||
flagFull = "full"
|
flagFull = "full"
|
||||||
|
flagInReplyTo = "in-reply-to"
|
||||||
flagInstance = "instance"
|
flagInstance = "instance"
|
||||||
flagLanguage = "language"
|
flagLanguage = "language"
|
||||||
flagLimit = "limit"
|
flagLimit = "limit"
|
||||||
|
|
Loading…
Reference in a new issue