server
server copied to clipboard
feat(pm & notification): pm related apis and a notification counting api
-
/pms/list
(GET):-
?folder=inbox
(收件箱) -
?folder=outbox
(已发送) example response
{ "data": [ { "created_at": "0001-01-01T00:00:00Z", "related_message": { "created_at": "0001-01-01T00:00:00Z", "title": "", "content": "", "id": 1, "new": false }, "sender": { "avatar": { "large": "", "medium": "", "small": "" }, "sign": "", "url": "", "username": "", "nickname": "", "id": 1, "user_group": 1 }, "receiver": { "avatar": { "large": "", "medium": "", "small": "" }, "sign": "", "url": "", "username": "", "nickname": "", "id": 2, "user_group": 1 }, "title": "", "content": "", "id": 2, "new": false } ] }
-
-
/pms/related-msgs/:id
(GET)
example response
[
{
"created_at": "0001-01-01T00:00:00Z",
"sender": {
"avatar": {
"large": "",
"medium": "",
"small": ""
},
"sign": "",
"url": "",
"username": "",
"nickname": "",
"id": 1,
"user_group": 1
},
"receiver": {
"avatar": {
"large": "",
"medium": "",
"small": ""
},
"sign": "",
"url": "",
"username": "",
"nickname": "",
"id": 2,
"user_group": 1
},
"title": "",
"content": "",
"id": 1,
"new": false
}
]
-
/pms/counts
(GET)
example response
{
"unread": 0,
"inbox": 0,
"outbox": 0
}
-
/pms/contacts/recent
(GET)(最新的15个收件人)
example response
[
{
"avatar": {
"large": "",
"medium": "",
"small": ""
},
"sign": "",
"url": "",
"username": "",
"nickname": "",
"id": 1,
"user_group": 1
}
]
-
/pms/read
(PATCH)(标记已读) example request body
{
"id": 1
}
成功返回204
-
/pms
(POST) example request body
{
"title": "",
"content": "",
"related_id": 1, // or empty
"receiver_ids": [1],
"sender_id": 1
}
example response
[
{
"created_at": "0001-01-01T00:00:00Z",
"sender": {
"avatar": {
"large": "",
"medium": "",
"small": ""
},
"sign": "",
"url": "",
"username": "",
"nickname": "",
"id": 1,
"user_group": 1
},
"receiver": {
"avatar": {
"large": "",
"medium": "",
"small": ""
},
"sign": "",
"url": "",
"username": "",
"nickname": "",
"id": 2,
"user_group": 1
},
"title": "",
"content": "",
"id": 1,
"new": false
}
]
-
/pms
(DELETE) example request body
{
"id": 1
}
成功返回204
-
/notifications/count
(GET) example response
0
Deploy Preview for bangumi-org-server ready!
Name | Link |
---|---|
Latest commit | c8608114609902b2e5b0a0bcd43fb96a7f33d64a |
Latest deploy log | https://app.netlify.com/sites/bangumi-org-server/deploys/635564842cf0c90008fdda99 |
Deploy Preview | https://deploy-preview-225--bangumi-org-server.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Codecov Report
Base: 51.31% // Head: 52.03% // Increases project coverage by +0.71%
:tada:
Coverage data is based on head (
582944a
) compared to base (6854154
). Patch coverage: 59.27% of modified lines in pull request are covered.
:exclamation: Current head 582944a differs from pull request most recent head dfc41d1. Consider uploading reports for the commit dfc41d1 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #225 +/- ##
==========================================
+ Coverage 51.31% 52.03% +0.71%
==========================================
Files 205 219 +14
Lines 8225 8960 +735
==========================================
+ Hits 4221 4662 +441
- Misses 3521 3740 +219
- Partials 483 558 +75
Impacted Files | Coverage Δ | |
---|---|---|
internal/web/handler/pm/list_recent_contact.go | 26.66% <26.66%> (ø) |
|
internal/pkg/generic/slice/slice.go | 86.90% <28.57%> (-5.31%) |
:arrow_down: |
internal/web/handler/pm/mark_read.go | 31.25% <31.25%> (ø) |
|
internal/notification/mysql_repository.go | 33.33% <33.33%> (ø) |
|
internal/web/handler/pm/list_related.go | 33.33% <33.33%> (ø) |
|
internal/ctrl/create_private_message.go | 34.00% <34.00%> (ø) |
|
internal/web/handler/pm/create.go | 40.54% <40.54%> (ø) |
|
internal/user/mysql_repository.go | 63.95% <41.17%> (-14.90%) |
:arrow_down: |
internal/web/req/query_parse.go | 43.58% <45.00%> (+0.29%) |
:arrow_up: |
internal/web/handler/pm/list.go | 46.93% <46.93%> (ø) |
|
... and 14 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
请求的URL感觉有点混搭?感觉获取和删除的消息用同一个path的不同方法就行了
请求的URL感觉有点混搭?感觉获取和删除的消息用同一个path的不同方法就行了
混搭是指api
里带上了method
吗,例如create
和delete
。没有/pms/:id(DELETE)
因为delete
是一个批量删除的方法,可以穿多个id
。获取消息是指/pms/list/:id
?这个是获取主消息下的所有消息,不是获取单条消息,所以如果用/pms/:id
好像不是很好。
可以改成?
/pms/list?folder=inbox => /pms/list/:folder
/pms/list/:id => /pms/related-msgs/:id
/pms/delete => /pms(DELETE)
/pms/create => /pms(POST)
感觉有点难搞,要不就都用RPC风格的URL吧。主要是感觉一开始提议的URL有RPC风格的有rest风格的不太统一,你觉得呢。
感觉有点难搞,要不就都用RPC风格的URL吧。主要是感觉一开始提议的URL有RPC风格的有rest风格的不太统一,你觉得呢。
刚查了下,RPC风格是用动词作为URL?例如get-list
,get-related-msgs
,然后方法一般只用GET
和POST
。这样的话,个人觉得URL有点累赘,而且也跟其他api
的风格不一致。
按我上一个comment
那样改,应该是符合rest
风格的吧?我偏向尽量都用rest
的🤔,命名觉得有问题还可以再改改
ok
ok
改了几个url
的命名
还是draft吗?还没完成吗?🤔
还是draft吗?还没完成吗?🤔
其实是完成了,不过感觉还有挺多地方要改,所以看看还有没有修改建议。那我先转正式PR
👀能解决一下冲突吗
/ping
👀 看起来ok,能写一下openapi吗
👀 看起来ok,能写一下openapi吗
好,我现在写下
方便拆成pm和通知两个PR吗?现在有通知的权限,pm的暂时还没做,也还没有权限
啊,没事了。才发现这个通知只有一个 count api。