feat: add ability to reply to statuses
This commit is contained in:
parent
ec282e207f
commit
2bb801b6d0
4 changed files with 20 additions and 6 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
|
||||
```
|
||||
- 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
|
||||
```
|
||||
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-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. | |
|
||||
| `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. | |
|
||||
| `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. | |
|
||||
|
|
|
@ -13,8 +13,12 @@ import (
|
|||
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||
)
|
||||
|
||||
const (
|
||||
baseStatusesPath string = "/api/v1/statuses"
|
||||
)
|
||||
|
||||
func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
||||
path := "/api/v1/statuses/" + statusID
|
||||
path := baseStatusesPath + "/" + statusID
|
||||
url := g.Authentication.Instance + path
|
||||
|
||||
var status model.Status
|
||||
|
@ -31,6 +35,7 @@ func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
|||
|
||||
type CreateStatusForm struct {
|
||||
Content string `json:"status"`
|
||||
InReplyTo string `json:"in_reply_to_id"`
|
||||
Language string `json:"language"`
|
||||
SpoilerText string `json:"spoiler_text"`
|
||||
Boostable bool `json:"boostable"`
|
||||
|
@ -57,7 +62,7 @@ func (g *Client) CreateStatus(form CreateStatusForm) (model.Status, error) {
|
|||
}
|
||||
|
||||
requestBody := bytes.NewBuffer(data)
|
||||
url := g.Authentication.Instance + "/api/v1/statuses"
|
||||
url := g.Authentication.Instance + baseStatusesPath
|
||||
|
||||
var status model.Status
|
||||
|
||||
|
@ -119,7 +124,7 @@ func (g *Client) RemoveStatusFromBookmarks(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 {
|
||||
return fmt.Errorf(
|
||||
|
@ -132,7 +137,7 @@ func (g *Client) LikeStatus(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 {
|
||||
return fmt.Errorf(
|
||||
|
@ -163,7 +168,7 @@ func (g *Client) GetLikedStatuses(limit int, resourceName string) (model.StatusL
|
|||
}
|
||||
|
||||
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 {
|
||||
return fmt.Errorf(
|
||||
|
@ -176,7 +181,7 @@ func (g *Client) ReblogStatus(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 {
|
||||
return fmt.Errorf(
|
||||
|
|
|
@ -32,6 +32,7 @@ type CreateExecutor struct {
|
|||
content string
|
||||
contentType string
|
||||
fromFile string
|
||||
inReplyTo string
|
||||
language string
|
||||
resourceType 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.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.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.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")
|
||||
|
@ -204,6 +206,7 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
|||
SpoilerText: c.spoilerText,
|
||||
Boostable: c.boostable,
|
||||
Federated: c.federated,
|
||||
InReplyTo: c.inReplyTo,
|
||||
Likeable: c.likeable,
|
||||
Replyable: c.replyable,
|
||||
Sensitive: sensitive,
|
||||
|
|
|
@ -25,6 +25,7 @@ const (
|
|||
flagFrom = "from"
|
||||
flagFromFile = "from-file"
|
||||
flagFull = "full"
|
||||
flagInReplyTo = "in-reply-to"
|
||||
flagInstance = "instance"
|
||||
flagLanguage = "language"
|
||||
flagLimit = "limit"
|
||||
|
|
Loading…
Reference in a new issue