Commit Graph
68 Commits
Author SHA1 Message Date
qwqcode 7c251fd067 feat(api/vote): add get vote status endpoint (#998)
A new HTTP API endpoint `GET /votes/:target_name/:target_id` is now available. (See https://artalk.js.org/http-api.html#tag/Vote/operation/GetVote)

- Implement GET endpoint for retrieving vote status
- Add tests for vote functionality

Related to: #997

This is a prerequisite PR for #983.
2024-10-06 22:31:59 +08:00
qwqcode 02a369fe5c refactor(api/vote): refactor vote http endpoint and logic (#997)
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.

- Change vote endpoint to include `{target_name}` and `{choice}`
- Update vote logic to handle `up` and `down` choices
- Modify request data models and API interfaces for new vote structure
- Ensure backward compatibility with existing vote response data
- Improve vote handling and response structure

BREAKING CHANGE: Vote HTTP API endpoint have been updated. (See #997)
2024-10-06 22:15:15 +08:00
qwqcode 6b0e46c86c refactor(go): hardcode version and get commit_hash via runtime/debug 2024-09-18 22:01:21 +08:00
qwqcode cf7725edba refactor(go): bump the module version and support go install (#979)
BREAKING CHANGE: The original Go module name was `github.com/ArtalkJS/Artalk`, which has now been modified to `github.com/artalkjs/artalk/v2` (all lowercase). This change may affect the CI pipeline or other areas if you are compiling the Artalk server and have specified the fixed Go module name. Regarding the original `-ldflags -X github.com/ArtalkJS/Artalk/internal/config.Version` and `CommitHash` definitions, please remove them, as they are now obsolete. The `Version` has been hardcoded into the Go code, and the `CommitHash` is now read from the Go build info via runtime/debug’s vcs.revision value. This change only affects the server developers and does not impact the frontend UI client.
2024-09-18 21:43:43 +08:00
qwqcode a98a50abbe test(mutex): add tests for keyed mutex 2024-09-16 16:55:38 +08:00
qwqcode 9fde40d843 chore(ci): improve golang build workflow on circle ci 2024-09-04 21:23:23 +08:00
qwqcode 4eb3dbaca2 fix(db): sql error with custom table prefix (#970) 2024-09-04 21:00:13 +08:00
qwqcode d2225d565b fix(anti_spam): handle empty referer variable in anti-spam check (#853) 2024-09-03 19:37:39 +08:00
qwqcode 4b5ec39b8e feat(auth): add user profile and password changing (#966) 2024-09-02 15:56:04 +08:00
qwqcode aa92a92961 fix(api/comment_add): improve the security of comment add api (#964)
* fix(api/comment_add): refactor and improve the security of comment add api

* update
2024-08-29 23:29:36 +08:00
qwqcode 04ef002da1 fix(sidebar): correct total item count for pagination in sidebar 2024-08-29 18:43:49 +08:00
qwqcode 8a9480d05a feat(ui/sidebar): add page search by keywords in sidebar (#603) 2024-08-29 13:42:41 +08:00
qwqcode 6b58fd8a9d feat(ui/sidebar): add user search by keywords in sidebar (#710) 2024-08-28 19:50:38 +08:00
qwqcode 059bac8b5f perf(api/auth): add more specific error messages for login failures 2024-08-28 11:26:31 +08:00
qwqcode 4d7e157ff0 fix(ui/sidebar): show env variables in sidebar settings ui (#946) (#956)
* fix(ui/sidebar): show env variables in sidebar settings ui (#946)

* fix unit test
2024-08-19 16:27:20 +08:00
qwqcode 68bcdbe3e8 fix(api/auth): migrate auth_identities when account merging (#920) 2024-07-12 13:26:27 +08:00
qwqcode 67922f34ad fix(api/auth): include render mustache params for verification email subject (#910) 2024-06-08 16:40:35 +08:00
qwqcode 2dfee533da fix(api/stats): fix site_pv response body and add unit tests (#896) 2024-05-29 10:57:14 +08:00
guangwu acb087887c fix(api/transfer_upload): close temp file in transfer upload endpoint (#877) 2024-05-25 18:22:50 +08:00
qwqcode dbb3c55148 refactor(transfer): improve the reliability of the transfer (#883) 2024-05-25 18:00:27 +08:00
qwqcode 45d1bc1241 fix(api/pv): add mutex for page pv record endpoint 2024-05-03 23:25:10 +08:00
qwqcode 88aec7e767 feat(auth): user accounts merge tool (#854) 2024-05-03 21:54:15 +08:00
qwqcode a09628c4e8 feat(auth): social login api endpoints (#854) 2024-05-03 21:54:06 +08:00
qwqcode f3e356e450 chore(template): tidy up template pkg naming 2024-05-02 17:19:40 +08:00
qwqcode 44742c149e fix(db/migrate): issue with root id generation 2024-04-24 23:04:09 +08:00
qwqcode ec6d2b2e60 fix(db/migrator): remove foreign key constraints and better root_id generation (#835)
Add function to delete all foreign key constraints when migration.

Leave relationship maintenance to the program and reduce the difficulty of database management. Because there are many different DBs and the implementation of foreign keys may be different, and the DB may not support foreign keys, so don't rely on the foreign key function of the DB system.
2024-04-14 23:46:22 +08:00
qwqcode 73d8ea97ed perf(conf/upgit): disallow custom executable path of upgit for security (#817)
BREAKING CHANGE: For UpGit users: Due to security reasons, Artalk no longer allows configuring the executable file path (img_upload.upgit.exec) for upgit. Please add it to system environment variables instead.
2024-04-07 21:43:44 +08:00
qwqcode c2c5a80d8d refactor(comments_get): reduce api complexity by introducing LiteDB (#800)
* refactor(comments_get): reduce interface complexity by introducing LiteDB

* test: add unit test

* add more unit test case
2024-04-07 19:17:01 +08:00
qwqcode b60cb585b6 perf(db): optimize N+1 query in comment list (#799) 2024-03-17 21:01:42 +08:00
qwqcode 929faf0722 fix(sidebar/login): cannot select a name with the same email upon login (#781) 2024-03-04 21:01:04 +08:00
qwqcode 8ff3f5e875 refactor(dao): validate the args of the FindCreateUser function 2024-02-14 00:21:48 +08:00
qwqcode 18123f7002 refactor(origin): extract CheckURLTrusted function 2024-02-12 20:36:43 +08:00
qwqcode cf2094667d feat(api/domain): add GET /conf/domain endpoint 2024-02-11 23:47:04 +08:00
qwqcode 2cd2165f06 refactor(entity/user): extract CheckPassword function 2024-02-11 23:36:19 +08:00
qwqcode 4eada4b628 feat(api/auth): invalidate old auth tokens after changing password 2024-02-11 23:34:32 +08:00
qwqcode 0097e041b1 fix(api/comments): ua field is optional and not required (#767) 2024-02-05 14:30:17 +08:00
qwqcode 191977c0df feat(api): add GET /comments/:id endpoint (#764) 2024-02-04 20:08:38 +08:00
qwqcode d97ad5c843 fix(ip_region): unable to output the IP region correctly (#760) 2024-02-03 21:43:42 +08:00
qwqcode bc1c4d315c fix(api/comments): counting comments issue in PostgreSQL db (#760) (#761) 2024-02-03 15:34:25 +08:00
qwqcode 0e0b53fe9e perf(ui/sidebar): prevent potential token leakage by clearing query in iframe url
The previous referrer policy was already set to `strict-origin`, but to further enhance security, this modification was made.
2024-01-30 23:07:37 +08:00
qwqcode a40a070bdb chore(fix/pin): fix pinned comment sort rule 2024-01-29 14:46:19 +08:00
qwqcode 589850d311 refactor(api): refactor HTTP API to version 2 (#735)
* refactor(api): refactor HTTP API to version 2

* refactor: remove forced site_origin check

* refactor: update http client

* fix

* add more api description and error code

* reduce nestings in response structures

* separate unread

* refactor(api/comments): get comments

* refactor: frontend api module

* chore: remove vite temporary file

* chore: restore swagger file

* update

* 移除为管理员分配站点名的站点隔离功能,简化实现

* refactor pagesAllFetch

* fix ci

* remove useless codes

* limiter protected paths

* add test for version endpoint

* rename handler code files

* code file separate

* fix some bug of interacting with backend

* add fetch error class for handling

* fix and rename

* refactor: checker support both `Promise` and callback fn

* fix new checker captcha iframe url

* rename and add swagger id field

* replace tab with spaces in go comment

* chore: refine

* complete the validate tag for request fields and enable `--defaultRequired`

90% of the request fields of our API are required,100% of response fields in our API are required.
Each field add validate:"required" is easy to miss.

* replace original api client with auto-generated codes

* artalk pkg apply new api client

* artalk-sidebar pkg apply new api client

* fix issues

* fix sidebar locale conf and refactor user login

* fix and refactor captcha and limiter

* fix ui testing

* add script to build http client by swagger.json
2024-01-24 21:33:30 +08:00
qwqcode e816dd686c fix(api/img-upload): public_path config enables the use of full url (#659) (#664) 2023-12-17 01:29:59 +08:00
qwqcode ec0ef12b0e refactor(anti_spam): refactor anti_spam pkg and add unit test (#589)
* refactor(anti_spam): refactor anti_spam pkg and add unit test

* add more test
2023-09-21 21:48:56 +08:00
qwqcode 6c35fe9ded fix(captcha): image captcha base64 response issue (#575) 2023-09-11 15:17:11 +08:00
qwqcode 2bdb806aaf refactor(conf): better config.NewFromFile with error handle 2023-09-01 17:02:05 +08:00
qwqcode dc333e5a9a refactor(core): better AppService func with error handle 2023-09-01 17:02:04 +08:00
qwqcode 2669b0efe8 perf(cmd): support command mini boot mode 2023-09-01 17:02:03 +08:00
qwqcode 1da3f6420e test(artransfer): add tests for artransfer 2023-09-01 17:02:02 +08:00
qwqcode 388b5b8b24 refactor(cache): refactor cache pkg 2023-09-01 17:02:00 +08:00