chore: prepare v2.0.0 release
This commit is contained in:
1 parent
1001f55a06
commit
c15b2d857d
31 files changed
+965
-40
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/core",
|
||||
"version": "1.14.22",
|
||||
"version": "2.0.0",
|
||||
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
commentQzoneMsg,
|
||||
deleteQzoneMsg,
|
||||
getQzoneFeeds,
|
||||
getQzoneMsgDetail,
|
||||
getQzoneMsgList,
|
||||
publishQzoneMsg,
|
||||
setQzoneBlack,
|
||||
@@ -10,6 +11,7 @@ import {
|
||||
uploadQzoneImageFromSource,
|
||||
type QzoneCommentResult,
|
||||
type QzoneFeedsResult,
|
||||
type QzoneMsgDetailResult,
|
||||
type QzoneMsgListResult,
|
||||
type QzonePublishResult,
|
||||
type QzoneUpdateRightResult,
|
||||
@@ -36,6 +38,18 @@ export class QzoneApi {
|
||||
return getQzoneMsgList(cookieObject, uin, pos, num);
|
||||
}
|
||||
|
||||
/** 获取说说详情和一页评论。省略 targetUin 时使用当前账号。 */
|
||||
async getMsgDetail(
|
||||
tid: string,
|
||||
targetUin?: number,
|
||||
pos = 0,
|
||||
num = 20,
|
||||
): Promise<QzoneMsgDetailResult> {
|
||||
const uin = targetUin === undefined ? this.ctx.identity.uin : String(targetUin);
|
||||
const cookieObject = await this.ctx.apis.web.getCookies('qzone.qq.com');
|
||||
return getQzoneMsgDetail(cookieObject, uin, tid, pos, num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取好友动态(feed)。`pageNum` 为 1 起的页码,`count` 为本页数量。
|
||||
* 始终以机器人自己的身份拉取好友动态。
|
||||
|
||||
@@ -20,6 +20,38 @@ describe('apis/qzone', () => {
|
||||
return { bridge, getCookies, fetchSpy };
|
||||
}
|
||||
|
||||
it.each([undefined, 20002])(
|
||||
'getMsgDetail uses current-account credentials for owner %s',
|
||||
async (targetUin) => {
|
||||
const { bridge, getCookies } = bridgeWithWeb();
|
||||
const detail = { tid: 'T1', content: 'Post', comment_num: 0, comments: [] };
|
||||
const fetchDetail = vi.spyOn(qzoneWeb, 'getQzoneMsgDetail').mockResolvedValue(detail);
|
||||
const result = await new QzoneApi(bridge as never).getMsgDetail('T1', targetUin);
|
||||
expect(result).toEqual(detail);
|
||||
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
|
||||
expect(fetchDetail).toHaveBeenCalledWith(
|
||||
{ p_skey: 'PSK' },
|
||||
String(targetUin ?? 10001),
|
||||
'T1',
|
||||
0,
|
||||
20,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('getMsgDetail passes pagination and propagates cookie and protocol failures', async () => {
|
||||
const { bridge, getCookies } = bridgeWithWeb();
|
||||
const api = new QzoneApi(bridge as never);
|
||||
const fetchDetail = vi
|
||||
.spyOn(qzoneWeb, 'getQzoneMsgDetail')
|
||||
.mockRejectedValue(new Error('denied'));
|
||||
await expect(api.getMsgDetail('T1', 20002, 10, 5)).rejects.toThrow('denied');
|
||||
expect(fetchDetail).toHaveBeenCalledWith({ p_skey: 'PSK' }, '20002', 'T1', 10, 5);
|
||||
getCookies.mockRejectedValueOnce(new Error('cookie failure'));
|
||||
await expect(api.getMsgDetail('T1')).rejects.toThrow('cookie failure');
|
||||
expect(fetchDetail).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("defaults target_uin to the bot's own uin and uses default pos/num", async () => {
|
||||
const { bridge, getCookies, fetchSpy } = bridgeWithWeb();
|
||||
await new QzoneApi(bridge as never).getMsgList();
|
||||
|
||||
Reference in new issue
Block a user