fix today memory after restart
release / docker-image (push) Successful in 1m8s
release / goreleaser (push) Successful in 10m14s

This commit is contained in:
2026-02-13 09:58:37 +03:00
parent 738dfda7a0
commit 2c6e71bad5
4 changed files with 83 additions and 3 deletions
+28
View File
@@ -67,6 +67,34 @@ func (c *Client) ListMemos(ctx context.Context, filter string, pageSize int, pag
return &result, nil
}
// GetMemo fetches a single memo by its resource name (e.g. "memos/123").
func (c *Client) GetMemo(ctx context.Context, name string) (*Memo, error) {
reqURL := fmt.Sprintf("%s/api/v1/%s", c.baseURL, name)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, http.NoBody)
if err != nil {
return nil, fmt.Errorf("create request: %w", err)
}
req.Header.Set("Authorization", "Bearer "+c.token)
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("do request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("memos API returned %d: %s", resp.StatusCode, body)
}
var memo Memo
if err := json.NewDecoder(resp.Body).Decode(&memo); err != nil {
return nil, fmt.Errorf("decode memo: %w", err)
}
return &memo, nil
}
// DownloadAttachment downloads the attachment data as bytes.
func (c *Client) DownloadAttachment(ctx context.Context, att Attachment) ([]byte, error) {
var reqURL string