Merge count endpoints into one?
There are currently 4 different endpoints for counts:
- /api/v4/community/pending_follows/count
- /api/v4/admin/registration_application/count
- /api/v4/account/report_count
- /api/v4/account/notification/count
Clients need to regularly call each for them which takes some resources and extra client logic. Instead we could merge all these into a single endpoint with separate fields for each type. The only disadvantage is that this would result in unnecessary db queries, eg if a client doesnt support reports but Lemmy still returns the report count every time. This could be avoided by adding params like include_report_count: bool.
I fully agree with consolidating them into a /account/counts, especially since these require initial and periodic fetching in front ends.
The only one that has a query param, is report_count, which allows an optional community_id for getting the number of reports for that community, but I'd be fine with removing it. I don't see how its that useful, especially since the reports tab is going to show all your reports anyway.
As long as its well structured, then we'd just not include things like registration applications for non-admins.
The only disadvantage is that this would result in unnecessary db queries, eg if a client doesnt support reports but Lemmy still returns the report count every time. This could be avoided by adding params like include_report_count: bool.
I don't think that's necessary, these are very fast reads, and we shouldn't start to add query params for clients with limited functionality, just let them ignore anything they don't use. Otherwise the possibilities for not including things based on query params are endless.