inital commit
This commit is contained in:
8
notes.go
8
notes.go
@@ -51,7 +51,7 @@ type Note struct {
|
||||
// (follow-the-Next-link), not page-numbered fetches.
|
||||
//
|
||||
// Requires a logged-in client.
|
||||
func (c *Client) Notes(ctx context.Context, opts ListOptions) iter.Seq2[*NotePreview, error] {
|
||||
func (c *Client) Notes(ctx context.Context, opts ListOptions, reqOpts ...Option) iter.Seq2[*NotePreview, error] {
|
||||
return func(yield func(*NotePreview, error) bool) {
|
||||
nextURL := urls.MsgPMs()
|
||||
pagesFetched := 0
|
||||
@@ -66,7 +66,7 @@ func (c *Client) Notes(ctx context.Context, opts ListOptions) iter.Seq2[*NotePre
|
||||
err := c.fetch(ctx, nextURL, func(doc *goquery.Document) error {
|
||||
items, next = parseNotesInboxPage(doc)
|
||||
return nil
|
||||
})
|
||||
}, reqOpts...)
|
||||
if err != nil {
|
||||
yield(nil, err)
|
||||
return
|
||||
@@ -87,7 +87,7 @@ func (c *Client) Notes(ctx context.Context, opts ListOptions) iter.Seq2[*NotePre
|
||||
|
||||
// GetNote fetches a single note (private message) by ID. Requires a
|
||||
// logged-in client.
|
||||
func (c *Client) GetNote(ctx context.Context, id NoteID) (*Note, error) {
|
||||
func (c *Client) GetNote(ctx context.Context, id NoteID, opts ...Option) (*Note, error) {
|
||||
if id <= 0 {
|
||||
return nil, fmt.Errorf("fa: GetNote: id must be > 0")
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (c *Client) GetNote(ctx context.Context, id NoteID) (*Note, error) {
|
||||
}
|
||||
out = n
|
||||
return nil
|
||||
})
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user