mattn / go-mastodon

mastodon client for golang
MIT License
599 stars 85 forks source link

Add more endpoints and some bug fixes #172

Open RasmusLindroth opened 1 year ago

RasmusLindroth commented 1 year ago

New features

Bug fixes

codecov-commenter commented 1 year ago

Codecov Report

Base: 87.51% // Head: 88.37% // Increases project coverage by +0.86% :tada:

Coverage data is based on head (2b33d0e) compared to base (9faaa4f). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #172 +/- ## ========================================== + Coverage 87.51% 88.37% +0.86% ========================================== Files 15 16 +1 Lines 1354 1437 +83 ========================================== + Hits 1185 1270 +85 + Misses 125 123 -2 Partials 44 44 ``` | [Impacted Files](https://codecov.io/gh/mattn/go-mastodon/pull/172?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn) | Coverage Δ | | |---|---|---| | [filters.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-ZmlsdGVycy5nbw==) | `96.55% <ø> (ø)` | | | [mastodon.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-bWFzdG9kb24uZ28=) | `73.86% <ø> (ø)` | | | [accounts.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-YWNjb3VudHMuZ28=) | `100.00% <100.00%> (ø)` | | | [lists.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-bGlzdHMuZ28=) | `95.16% <100.00%> (ø)` | | | [notification.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-bm90aWZpY2F0aW9uLmdv) | `80.76% <100.00%> (+1.89%)` | :arrow_up: | | [status.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-c3RhdHVzLmdv) | `82.26% <100.00%> (+1.21%)` | :arrow_up: | | [streaming.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-c3RyZWFtaW5nLmdv) | `97.70% <100.00%> (+0.12%)` | :arrow_up: | | [streaming\_ws.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-c3RyZWFtaW5nX3dzLmdv) | `97.82% <100.00%> (+1.67%)` | :arrow_up: | | [tags.go](https://codecov.io/gh/mattn/go-mastodon/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn#diff-dGFncy5nbw==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mattn)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

praccu commented 1 year ago

Hi!

Drive-by comment, because I've been looking at this repo and thinking about a problem you're touching:

I suspect that adding "parameter" struct arguments would be more durable than adding individual functions for every type of parameter you wish to pass.

For example, in this change, you propose adding GetNotificationsExclude with a string[] of excludes:

func (c *Client) GetNotificationsExclude(ctx context.Context, exclude *[]string, pg *Pagination) ([]*Notification, error

For endpoints that need to be added with > a dozen [0] optional parameters, this is not going to work.

I'd propose, instead, modifying GetNotifications to take a new parameter struct as an argument:

type NotificationsParams struct {
    MaxID               ID
    SinceID              ID
    MinID                ID
    Limit                  int64
    Types                []string
    ExcludeTypes    []string
    AccountID         ID
}

func (c *Client) GetNotifications(ctx context.Context, params NotificationParams, pg *Pagination) ([]*Notification, error

I think that "param" structs with one field per potential argument would be easy for users of this API, by making the behavior much more consistent. By keeping the names of the functions matching the API endpoint names, and providing a consistent mechanism for specifying all params, we can reduce confusion and provide a single style for supporting all endpoints and params.

[0] https://docs.joinmastodon.org/methods/admin/accounts/#v1 [1] https://docs.joinmastodon.org/methods/notifications/#query-parameters