feat(qzone): add set_qzone_msg_right to change a feed's visibility (#186)
* feat(qzone): add set_qzone_msg_right to change a feed's visibility Add updateQzoneMsgRight in the protocol layer, porting php-qzone's updateRight: fetch the feed via emotion_cgi_msgdetail_v6, rebuild the full publish-shaped payload (richval/pic_bo/con), then override ugc_right/allow_uins and POST to emotion_cgi_update. Expose it through QzoneApi.updateRight and the OneBot set_qzone_msg_right action, with the same ugc_right/target_uins validation as send_qzone_msg. Covered by protocol, core and onebot tests. * fix(qzone): make qzoneParse more stable and fixed a test example
This commit is contained in:
1 parent
3e99d3bb5a
commit
884db940df
8 files changed
+653
-7
No files matched your search
@@ -5,11 +5,13 @@ import {
|
||||
getQzoneMsgList,
|
||||
publishQzoneMsg,
|
||||
setQzoneLike,
|
||||
updateQzoneMsgRight,
|
||||
uploadQzoneImageFromSource,
|
||||
type QzoneCommentResult,
|
||||
type QzoneFeedsResult,
|
||||
type QzoneMsgListResult,
|
||||
type QzonePublishResult,
|
||||
type QzoneUpdateRightResult,
|
||||
type QzoneUploadImageResult,
|
||||
} from '@snowluma/protocol/web/qzone';
|
||||
import type { BridgeContext } from '../bridge-context';
|
||||
@@ -74,6 +76,15 @@ export class QzoneApi {
|
||||
await deleteQzoneMsg(cookieObject, this.ctx.identity.uin, tid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改机器人自己空间一条已发说说的查看权限(按 tid)。
|
||||
* `ugcRight` / `targetUins` 含义同 publish(16/128 时 targetUins 必填)。
|
||||
*/
|
||||
async updateRight(tid: string, ugcRight: number, targetUins?: string): Promise<QzoneUpdateRightResult> {
|
||||
const cookieObject = await this.ctx.apis.web.getCookies('qzone.qq.com');
|
||||
return updateQzoneMsgRight(cookieObject, this.ctx.identity.uin, tid, ugcRight, targetUins);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给一条说说点赞/取消赞。`targetUin` 省略时点赞机器人自己空间的说说;
|
||||
* 点赞好友说说时传好友 uin(tid 来自 get_qzone_feeds / get_qzone_msg_list)。
|
||||
|
||||
@@ -117,6 +117,16 @@ describe('apis/qzone', () => {
|
||||
expect(delSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 'TID9');
|
||||
});
|
||||
|
||||
it('updateRight changes a feed\'s visibility on the bot\'s own space', async () => {
|
||||
const getCookies = vi.fn(async () => ({ p_skey: 'PSK' }));
|
||||
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
|
||||
const updSpy = vi.spyOn(qzoneWeb, 'updateQzoneMsgRight').mockResolvedValue({ ugc_right: 16 });
|
||||
const out = await new QzoneApi(bridge as never).updateRight('TID9', 16, '10002|10003');
|
||||
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
|
||||
expect(updSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 'TID9', 16, '10002|10003');
|
||||
expect(out).toEqual({ ugc_right: 16 });
|
||||
});
|
||||
|
||||
it('like defaults the feed owner to self and passes opUin=self + like flag', async () => {
|
||||
const getCookies = vi.fn(async () => ({ p_skey: 'PSK' }));
|
||||
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
|
||||
|
||||
Reference in new issue
Block a user