ArtalkJS / Artalk

🌌 Your Self-hosted Comment System. | 自托管评论系统
https://artalk.js.org
MIT License
1.67k stars 142 forks source link

refactor(api/vote): refactor vote http endpoint and logic #997

Closed qwqcode closed 1 month ago

qwqcode commented 1 month ago

The original POST /votes/:type/:target_id endpoint for creating votes has been updated to POST /votes/:target_name/:target_id/:choice. The target_name can be either comment or page, the target_id is a numeric value, and the choice can be up or down. (https://artalk.js.org/http-api.html#tag/Vote/operation/CreateVote)

The HTTP response now includes two additional fields: is_up and is_down, which indicate the user's current voting state. The up and down fields remain unchanged and continue to be of numeric type, ensuring backward compatibility with existing clients.

BREAKING CHANGE: Vote HTTP API endpoint have been updated. (See #997)

This is a prerequisite PR for #983.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 70 lines in your changes missing coverage. Please review.

Project coverage is 32.16%. Comparing base (abac3f0) to head (9046996). Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
server/handler/vote.go 0.00% 66 Missing :warning:
internal/dao/query_find.go 0.00% 3 Missing :warning:
server/server.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #997 +/- ## ========================================== - Coverage 32.24% 32.16% -0.08% ========================================== Files 206 206 Lines 6888 6904 +16 ========================================== Hits 2221 2221 - Misses 4513 4529 +16 Partials 154 154 ``` | [Flag](https://app.codecov.io/gh/ArtalkJS/Artalk/pull/997/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ArtalkJS) | Coverage Δ | | |---|---|---| | [go](https://app.codecov.io/gh/ArtalkJS/Artalk/pull/997/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ArtalkJS) | `32.16% <0.00%> (-0.08%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ArtalkJS#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.