From 68b2a1ba2615c19642c8417d1350b9c6b867b1bb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 4 Oct 2024 10:31:35 +0300 Subject: initial secrets config and initial mastodon --- internal/platforms/mastodon/mastodon.go | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 internal/platforms/mastodon/mastodon.go (limited to 'internal/platforms') diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go new file mode 100644 index 0000000..e31947c --- /dev/null +++ b/internal/platforms/mastodon/mastodon.go @@ -0,0 +1,42 @@ +package mastodon + +import ( + "context" + + "codeberg.org/snonux/gos/internal/config" + "codeberg.org/snonux/gos/internal/entry" +) + +func Post(ctx context.Context, args config.Args, ent entry.Entry) error { + // payload := map[string]string{"status": status} + // payloadBytes, err := json.Marshal(payload) + // if err != nil { + // return fmt.Errorf("failed to marshal payload: %w", err) + // } + + // // Create the HTTP request + // req, err := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes)) + // if err != nil { + // return fmt.Errorf("failed to create request: %w", err) + // } + + // // Set headers + // req.Header.Set("Authorization", "Bearer "+config.AccessToken) + // req.Header.Set("Content-Type", "application/json") + + // // Execute the request + // client := &http.Client{} + // resp, err := client.Do(req) + // if err != nil { + // return fmt.Errorf("request failed: %w", err) + // } + // defer resp.Body.Close() + + // // Check for HTTP errors + // if resp.StatusCode != http.StatusOK { + // return fmt.Errorf("unexpected status code: %d", resp.StatusCode) + // } + + // fmt.Println("Message posted to Mastodon successfully") + return nil +} -- cgit v1.2.3