Skip to content

Commit

Permalink
Implemented inReplyTo and uploads for new toots
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Apr 3, 2021
1 parent 3b66846 commit a598222
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mast/timeline.go
Expand Up @@ -102,13 +102,32 @@ func (timeline *Timeline) Load() (error) {
return nil
}

func (timeline *Timeline) Toot(status *string, inReplyTo int, filesToUpload *[]string, visibility *string, sensitive bool, spoiler *string) (*mastodon.Status, error) {
func (timeline *Timeline) Toot(status *string, inReplyTo int, filesToUpload []string, visibility *string, sensitive bool, spoiler *string) (*mastodon.Status, error) {
newToot := mastodon.Toot{
Status: *status,
Visibility: *visibility,
Sensitive: sensitive,
SpoilerText: *spoiler,
}

if inReplyTo > -1 {
newToot.InReplyToID = timeline.Toots[inReplyTo].Status.ID
}

if len(filesToUpload) > 0 {
var mediaIDs []mastodon.ID

for _, fileToUpload := range filesToUpload {
attachment, err := timeline.client.UploadMedia(context.Background(), fileToUpload)
if err != nil {
return nil, err
}

mediaIDs = append(mediaIDs, attachment.ID)
}

newToot.MediaIDs = mediaIDs
}

return timeline.client.PostStatus(context.Background(), &newToot)
}

0 comments on commit a598222

Please sign in to comment.