feat(onebot): add public Qzone feeds and interactions (#587)
Add public Qzone discovery, pagination, and interactions with SDK and MCP support.
This commit is contained in:
20 files changed
+4997
-6
No files matched your search
@@ -181,6 +181,52 @@ for (const comment of detail.comments) {
|
||||
|
||||
分页参数及 `commentlist` / `list_3` 字段参考 [Qzone-API](https://github.com/SmartHypercube/Qzone-API/blob/master/qzone.py)。实际分页和可见内容取决于 QQ 空间服务端。
|
||||
|
||||
### 空友爱看与公共空间
|
||||
|
||||
公共空间动作使用推荐域 `3` 的 JSON 接口,与上面的旧空间 CGI 动作分开。先读取 `get_qzone_public_feeds`,再把返回的完整 `feed` 对象传给详情和互动动作,保留其中的身份、传递数据及未知字段;不要用旧说说 `tid` 拼造。
|
||||
|
||||
| 动作 | 主要参数 |
|
||||
| --- | --- |
|
||||
| `get_qzone_public_capabilities` | 无;读取当前账号的入口能力 |
|
||||
| `get_qzone_public_feeds` | 可选 `cursor` |
|
||||
| `get_qzone_public_feed_detail` | `feed` |
|
||||
| `get_qzone_public_comments` | `feed`、`cursor` |
|
||||
| `get_qzone_public_replies` | `feed`、完整 `comment`,可选 `cursor`、`page_size`(默认 20) |
|
||||
| `set_qzone_public_upvote` / `set_qzone_public_like` / `set_qzone_public_follow` | `feed`,可选 `enable`(默认 `true`,`false` 取消) |
|
||||
| `set_qzone_public_comment_like` | `feed`、完整 `comment`,可选完整 `reply`、`enable`(默认 `true`) |
|
||||
| `comment_qzone_public_feed` | `feed`、`content` |
|
||||
| `reply_qzone_public_feed` | `feed`、完整 `comment`、`content`,可选完整 `reply` |
|
||||
| `delete_qzone_public_comment` / `delete_qzone_public_reply` | `feed`、完整 `comment`;删除回复还需完整 `reply` |
|
||||
| `forward_qzone_public_feed` | `feed`,可选 `reason`(默认空字符串) |
|
||||
|
||||
“推”与“赞”是不同的互动,分别使用 `set_qzone_public_upvote` 和 `set_qzone_public_like`。评论或回复的 `content` 接受非空文本或非空的上游富文本对象数组。详情、评论、回复及写操作保留上游结果字段,`raw` 返回这些 JSON 对象;列表的 `feeds` 已去掉上游每项的 `.feed` 包装,其余字段保持开放。
|
||||
|
||||
QQ 上游会对评论换行做归一化,返回的富文本保持上游格式。
|
||||
|
||||
`set_qzone_public_comment_like` 为评论点赞;提供 `reply` 时改为给该回复点赞,`enable: false` 取消。保留评论或回复自带的 `like.id`,不要将它替换成评论 ID。
|
||||
|
||||
```ts
|
||||
const page = await bot.raw('get_qzone_public_feeds', {});
|
||||
if (page.has_more && page.next_cursor) {
|
||||
const next = await bot.raw('get_qzone_public_feeds', { cursor: page.next_cursor });
|
||||
console.log(next.feeds);
|
||||
}
|
||||
|
||||
const feed = page.feeds[0];
|
||||
if (feed) {
|
||||
const detail = await bot.raw('get_qzone_public_feed_detail', { feed });
|
||||
if (detail.has_more === true && typeof detail.attach_info === 'string') {
|
||||
const comments = await bot.raw('get_qzone_public_comments', {
|
||||
feed,
|
||||
cursor: detail.attach_info,
|
||||
});
|
||||
console.log(comments);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
列表续页必须原样传回 `next_cursor`,根据 `has_more` 判断结束,不能因本页不足 10 条而停止。详情中的首批评论位于 `feed.feed.cell_comment.comments`;后续评论使用详情或上一评论页的 `attach_info` 作为 `cursor`。读取回复时,首次可省略 `cursor` 使用完整评论自带的 `reply_attach_info`,之后传上一回复页的 `reply_attach_info`。这些游标各有用途,列表游标还绑定当前账号。登录或访问权限失败会抛出 `SnowLumaApiError`。
|
||||
|
||||
## Message Builder
|
||||
|
||||
```ts
|
||||
|
||||
@@ -144,12 +144,15 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'cancel_group_album_media_like',
|
||||
'clean_stream_temp_file',
|
||||
'comment_qzone',
|
||||
'comment_qzone_public_feed',
|
||||
'create_flash_task',
|
||||
'del_group_album_media',
|
||||
'delete_custom_face',
|
||||
'delete_flash_file',
|
||||
'delete_group_tag',
|
||||
'delete_qzone_msg',
|
||||
'delete_qzone_public_comment',
|
||||
'delete_qzone_public_reply',
|
||||
'do_group_album_comment',
|
||||
'download_file_image_stream',
|
||||
'download_file_record_stream',
|
||||
@@ -162,6 +165,7 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'get_record_text',
|
||||
'fetch_super_face_id',
|
||||
'fetch_sys_faces',
|
||||
'forward_qzone_public_feed',
|
||||
'get_doubt_friends_add_request',
|
||||
'get_fileset_id',
|
||||
'get_fileset_info',
|
||||
@@ -180,6 +184,11 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'get_qzone_msg_detail',
|
||||
'get_qzone_msg_list',
|
||||
'get_qzone_profile',
|
||||
'get_qzone_public_capabilities',
|
||||
'get_qzone_public_comments',
|
||||
'get_qzone_public_feed_detail',
|
||||
'get_qzone_public_feeds',
|
||||
'get_qzone_public_replies',
|
||||
'get_rkey_server',
|
||||
'get_share_link',
|
||||
'like_qzone',
|
||||
@@ -187,6 +196,7 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'modify_custom_face',
|
||||
'move_custom_face_to_front',
|
||||
'rename_flash_file',
|
||||
'reply_qzone_public_feed',
|
||||
'request_decrypt_key',
|
||||
'search_sys_faces',
|
||||
'send_ark_share',
|
||||
@@ -205,6 +215,10 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'set_qzone_ban',
|
||||
'set_qzone_msg_right',
|
||||
'set_qzone_profile',
|
||||
'set_qzone_public_comment_like',
|
||||
'set_qzone_public_follow',
|
||||
'set_qzone_public_like',
|
||||
'set_qzone_public_upvote',
|
||||
'share_group_ex',
|
||||
'share_peer',
|
||||
'test_download_stream',
|
||||
|
||||
@@ -84,6 +84,7 @@ import type {
|
||||
ActionUserIdParams,
|
||||
AddCustomFaceParams,
|
||||
CommentQzoneParams,
|
||||
CommentQzonePublicFeedParams,
|
||||
CreateFlashTaskParams,
|
||||
CustomFaceIdParams,
|
||||
DownloadFileStreamParams,
|
||||
@@ -98,12 +99,22 @@ import type {
|
||||
GetQzoneFeedsParams,
|
||||
GetQzoneMsgListParams,
|
||||
GetQzoneProfileParams,
|
||||
GetQzonePublicFeedsParams,
|
||||
GetQzonePublicCommentsParams,
|
||||
GetQzonePublicRepliesParams,
|
||||
GroupAlbumCommentParams,
|
||||
GroupAlbumMediaLikeParams,
|
||||
GroupAlbumMediaParams,
|
||||
LikeQzoneParams,
|
||||
ModifyCustomFaceParams,
|
||||
QzoneMsgIdParams,
|
||||
QzonePublicFeedParams,
|
||||
QzonePublicCommentParams,
|
||||
QzonePublicReplyParams,
|
||||
QzonePublicInteractionParams,
|
||||
SetQzonePublicCommentLikeParams,
|
||||
ReplyQzonePublicFeedParams,
|
||||
ForwardQzonePublicFeedParams,
|
||||
RenameFlashFileParams,
|
||||
RequestDecryptKeyParams,
|
||||
SendFlashMsgParams,
|
||||
@@ -187,6 +198,7 @@ import type {
|
||||
QzoneMsgListResult,
|
||||
QzonePublishResult,
|
||||
QzoneProfileResult,
|
||||
QzonePublicFeedsPage,
|
||||
QzoneUpdateRightResult,
|
||||
RkeyServerResult,
|
||||
SendFlashMsgResult,
|
||||
@@ -361,11 +373,14 @@ export interface SnowLumaActionMap {
|
||||
};
|
||||
clean_stream_temp_file: { params: JsonObject; data: CleanStreamTempFileResult };
|
||||
comment_qzone: { params: CommentQzoneParams; data: QzoneCommentResult };
|
||||
comment_qzone_public_feed: { params: CommentQzonePublicFeedParams; data: JsonObject };
|
||||
create_flash_task: { params: CreateFlashTaskParams; data: CreateFlashTaskResult };
|
||||
del_group_album_media: { params: GroupAlbumMediaParams; data: DeleteGroupAlbumMediaResult };
|
||||
delete_custom_face: { params: CustomFaceIdParams; data: EmptyData };
|
||||
delete_flash_file: { params: FilesetIdParams; data: EmptyData };
|
||||
delete_qzone_msg: { params: QzoneMsgIdParams; data: EmptyData };
|
||||
delete_qzone_public_comment: { params: QzonePublicCommentParams; data: JsonObject };
|
||||
delete_qzone_public_reply: { params: QzonePublicReplyParams; data: JsonObject };
|
||||
do_group_album_comment: { params: GroupAlbumCommentParams; data: GroupAlbumCommentResult };
|
||||
download_file_image_stream: {
|
||||
params: DownloadFileStreamParams;
|
||||
@@ -400,6 +415,11 @@ export interface SnowLumaActionMap {
|
||||
get_qzone_feeds: { params: GetQzoneFeedsParams; data: QzoneFeedsResult };
|
||||
get_qzone_msg_list: { params: GetQzoneMsgListParams; data: QzoneMsgListResult };
|
||||
get_qzone_profile: { params: GetQzoneProfileParams; data: QzoneProfileResult };
|
||||
get_qzone_public_capabilities: { params: JsonObject; data: JsonObject };
|
||||
get_qzone_public_feeds: { params: GetQzonePublicFeedsParams; data: QzonePublicFeedsPage };
|
||||
get_qzone_public_feed_detail: { params: QzonePublicFeedParams; data: JsonObject };
|
||||
get_qzone_public_comments: { params: GetQzonePublicCommentsParams; data: JsonObject };
|
||||
get_qzone_public_replies: { params: GetQzonePublicRepliesParams; data: JsonObject };
|
||||
get_rkey_server: { params: JsonObject; data: RkeyServerResult };
|
||||
get_share_link: { params: FilesetIdParams; data: string };
|
||||
like_qzone: { params: LikeQzoneParams; data: EmptyData };
|
||||
@@ -407,6 +427,7 @@ export interface SnowLumaActionMap {
|
||||
modify_custom_face: { params: ModifyCustomFaceParams; data: EmptyData };
|
||||
move_custom_face_to_front: { params: CustomFaceIdParams; data: EmptyData };
|
||||
rename_flash_file: { params: RenameFlashFileParams; data: EmptyData };
|
||||
reply_qzone_public_feed: { params: ReplyQzonePublicFeedParams; data: JsonObject };
|
||||
request_decrypt_key: { params: RequestDecryptKeyParams; data: DecryptKeyResult };
|
||||
send_ark_share: { params: SharePeerParams; data: ArkShareResult };
|
||||
send_flash_msg: { params: SendFlashMsgParams; data: SendFlashMsgResult };
|
||||
@@ -428,6 +449,11 @@ export interface SnowLumaActionMap {
|
||||
set_qzone_ban: { params: SetQzoneBanParams; data: EmptyData };
|
||||
set_qzone_msg_right: { params: SetQzoneMsgRightParams; data: QzoneUpdateRightResult };
|
||||
set_qzone_profile: { params: SetQzoneProfileParams; data: EmptyData };
|
||||
set_qzone_public_upvote: { params: QzonePublicInteractionParams; data: JsonObject };
|
||||
set_qzone_public_comment_like: { params: SetQzonePublicCommentLikeParams; data: JsonObject };
|
||||
set_qzone_public_like: { params: QzonePublicInteractionParams; data: JsonObject };
|
||||
set_qzone_public_follow: { params: QzonePublicInteractionParams; data: JsonObject };
|
||||
forward_qzone_public_feed: { params: ForwardQzonePublicFeedParams; data: JsonObject };
|
||||
share_group_ex: { params: ActionGroupIdParams; data: string };
|
||||
share_peer: { params: SharePeerParams; data: ArkShareResult };
|
||||
test_download_stream: { params: TestDownloadStreamParams; data: TestDownloadStreamResult };
|
||||
|
||||
@@ -589,6 +589,66 @@ export type SetQzoneProfileParams = JsonObject &
|
||||
| { name?: ActionStringInput; description: ActionStringInput }
|
||||
);
|
||||
|
||||
/** Non-empty text or a non-empty array of upstream rich-text items. */
|
||||
export type QzonePublicContent = string | JsonObject[];
|
||||
|
||||
export interface GetQzonePublicFeedsParams extends JsonObject {
|
||||
/** Opaque account-bound next_cursor from the previous page. */
|
||||
cursor?: string;
|
||||
}
|
||||
|
||||
export interface QzonePublicFeedParams extends JsonObject {
|
||||
/** The original feed cells returned in get_qzone_public_feeds.feeds. */
|
||||
feed: JsonObject;
|
||||
}
|
||||
|
||||
export interface GetQzonePublicCommentsParams extends QzonePublicFeedParams {
|
||||
/** Upstream attach_info from the detail or previous comment page. */
|
||||
cursor: string;
|
||||
}
|
||||
|
||||
export interface QzonePublicCommentParams extends QzonePublicFeedParams {
|
||||
/** Preserve the complete upstream parent comment. */
|
||||
comment: JsonObject;
|
||||
}
|
||||
|
||||
export interface GetQzonePublicRepliesParams extends QzonePublicCommentParams {
|
||||
/** Omit to use comment.reply_attach_info; then pass the reply page's cursor unchanged. */
|
||||
cursor?: string;
|
||||
/** Defaults to 20; must be at least 1. */
|
||||
page_size?: ActionNumberInput;
|
||||
}
|
||||
|
||||
export interface QzonePublicInteractionParams extends QzonePublicFeedParams {
|
||||
/** Defaults to true; false cancels the interaction. */
|
||||
enable?: ActionBooleanInput;
|
||||
}
|
||||
|
||||
export interface SetQzonePublicCommentLikeParams extends QzonePublicCommentParams {
|
||||
/** Omit for the parent comment; provide the complete upstream reply to like that reply. */
|
||||
reply?: JsonObject;
|
||||
/** Defaults to true; false cancels the like. */
|
||||
enable?: ActionBooleanInput;
|
||||
}
|
||||
|
||||
export interface CommentQzonePublicFeedParams extends QzonePublicFeedParams {
|
||||
content: QzonePublicContent;
|
||||
}
|
||||
|
||||
export interface ReplyQzonePublicFeedParams extends CommentQzonePublicFeedParams {
|
||||
comment: JsonObject;
|
||||
/** Preserve a specific upstream reply when addressing its author. */
|
||||
reply?: JsonObject;
|
||||
}
|
||||
|
||||
export interface QzonePublicReplyParams extends QzonePublicCommentParams {
|
||||
reply: JsonObject;
|
||||
}
|
||||
|
||||
export interface ForwardQzonePublicFeedParams extends QzonePublicFeedParams {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface QzoneMsgIdParams extends JsonObject {
|
||||
tid: ActionStringInput;
|
||||
}
|
||||
|
||||
@@ -401,6 +401,15 @@ export interface QzoneProfileResult extends JsonObject {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface QzonePublicFeedsPage extends JsonObject {
|
||||
/** Original feed cells, with the upstream item.feed wrapper removed. */
|
||||
feeds: JsonObject[];
|
||||
/** Controls pagination even when a page contains fewer than ten items. */
|
||||
has_more: boolean;
|
||||
/** Account-bound continuation; null when the list ends. */
|
||||
next_cursor: string | null;
|
||||
}
|
||||
|
||||
export interface QzoneFeed extends JsonObject {
|
||||
uin: number;
|
||||
nickname: string;
|
||||
|
||||
+99
@@ -8,6 +8,24 @@ const fileset = { fileset_id: 'fileset' };
|
||||
const flashFile = { ...fileset, file_name: 'file.txt', file_index: '0' };
|
||||
const peer = { group_id: '10001', user_id: '10002', phone_number: '' };
|
||||
const qzoneLike = { tid: 'post', target_uin: '10002', abstime: '1700000000' };
|
||||
const qzonePublicFeed = {
|
||||
cell_common: {
|
||||
domain_type: 3,
|
||||
union_id: { uf_key: '9007199254740993', unknown_identity: 'preserved' },
|
||||
},
|
||||
cell_feed_transfer: { opaque: 'fixture' },
|
||||
unknown_cell: { decimal: '18446744073709551615' },
|
||||
};
|
||||
const qzonePublicComment = {
|
||||
id: '9007199254740993',
|
||||
user: { uid: 'public-reader' },
|
||||
like: { id: 'comment-like-key' },
|
||||
};
|
||||
const qzonePublicReply = {
|
||||
id: '18446744073709551615',
|
||||
user: { uid: 'public-author' },
|
||||
like: { id: 'reply-like-key' },
|
||||
};
|
||||
|
||||
// The same examples are compiled against the published declarations and parsed
|
||||
// by the real server action definitions. They never invoke QQ or perform I/O.
|
||||
@@ -26,6 +44,10 @@ export const actionParams = {
|
||||
reply_uin: '10004',
|
||||
reply_name: 'Reader',
|
||||
},
|
||||
comment_qzone_public_feed: {
|
||||
feed: qzonePublicFeed,
|
||||
content: [{ type: 0, content: 'Comment', upstream_option: true }],
|
||||
},
|
||||
create_flash_task: {
|
||||
files: ['file:///one', { file: 'file:///two', name: 'two.txt' }],
|
||||
name: 'Files',
|
||||
@@ -35,6 +57,12 @@ export const actionParams = {
|
||||
delete_custom_face: { emoji_id: 'face' },
|
||||
delete_flash_file: fileset,
|
||||
delete_qzone_msg: { tid: 'post' },
|
||||
delete_qzone_public_comment: { feed: qzonePublicFeed, comment: qzonePublicComment },
|
||||
delete_qzone_public_reply: {
|
||||
feed: qzonePublicFeed,
|
||||
comment: qzonePublicComment,
|
||||
reply: qzonePublicReply,
|
||||
},
|
||||
do_group_album_comment: { ...album, lloc: 'photo', content: 'Comment' },
|
||||
download_file_image_stream: download,
|
||||
download_file_record_stream: download,
|
||||
@@ -42,6 +70,7 @@ export const actionParams = {
|
||||
download_fileset: flashFile,
|
||||
fetch_custom_face_detail: { count: '48' },
|
||||
fetch_ptt_text: { message_id: -42 },
|
||||
forward_qzone_public_feed: { feed: qzonePublicFeed, reason: '' },
|
||||
get_ptt_text: { message_id: '-42' },
|
||||
get_record_text: { message_id: -42 },
|
||||
get_doubt_friends_add_request: { count: '50' },
|
||||
@@ -57,6 +86,16 @@ export const actionParams = {
|
||||
get_qzone_feeds: { page_num: '1', count: '10', cursor: 'cursor-from-previous-response' },
|
||||
get_qzone_msg_list: { target_uin: '10002', pos: '0', num: '20' },
|
||||
get_qzone_profile: { target_uin: '10002' },
|
||||
get_qzone_public_capabilities: {},
|
||||
get_qzone_public_comments: { feed: qzonePublicFeed, cursor: 'comments-from-detail' },
|
||||
get_qzone_public_feed_detail: { feed: qzonePublicFeed },
|
||||
get_qzone_public_feeds: { cursor: 'public-feed-cursor' },
|
||||
get_qzone_public_replies: {
|
||||
feed: qzonePublicFeed,
|
||||
comment: qzonePublicComment,
|
||||
cursor: '',
|
||||
page_size: '20',
|
||||
},
|
||||
get_rkey_server: {},
|
||||
get_share_link: fileset,
|
||||
like_qzone: qzoneLike,
|
||||
@@ -64,6 +103,12 @@ export const actionParams = {
|
||||
modify_custom_face: { emoji_id: 'face', desc: 'Description' },
|
||||
move_custom_face_to_front: { emoji_id: 'face' },
|
||||
rename_flash_file: { ...fileset, new_name: 'new.txt' },
|
||||
reply_qzone_public_feed: {
|
||||
feed: qzonePublicFeed,
|
||||
comment: qzonePublicComment,
|
||||
content: 'Reply',
|
||||
reply: qzonePublicReply,
|
||||
},
|
||||
request_decrypt_key: { db_path: '/fixture.db' },
|
||||
send_ark_share: peer,
|
||||
send_flash_msg: { ...fileset, group_id: '10001', user_id: '10002' },
|
||||
@@ -101,6 +146,15 @@ export const actionParams = {
|
||||
set_qzone_ban: { user_id: '10002', enable: false },
|
||||
set_qzone_msg_right: { tid: 'post', ugc_right: '128', target_uins: ['10002'] },
|
||||
set_qzone_profile: { name: 'Space', description: '' },
|
||||
set_qzone_public_follow: { feed: qzonePublicFeed, enable: 'off' },
|
||||
set_qzone_public_comment_like: {
|
||||
feed: qzonePublicFeed,
|
||||
comment: qzonePublicComment,
|
||||
reply: qzonePublicReply,
|
||||
enable: 'on',
|
||||
},
|
||||
set_qzone_public_like: { feed: qzonePublicFeed, enable: 0 },
|
||||
set_qzone_public_upvote: { feed: qzonePublicFeed, enable: true },
|
||||
share_group_ex: { group_id: '10001' },
|
||||
share_peer: peer,
|
||||
test_download_stream: { error: false },
|
||||
@@ -131,11 +185,14 @@ export type CoveredAction =
|
||||
| 'cancel_group_album_media_like'
|
||||
| 'clean_stream_temp_file'
|
||||
| 'comment_qzone'
|
||||
| 'comment_qzone_public_feed'
|
||||
| 'create_flash_task'
|
||||
| 'del_group_album_media'
|
||||
| 'delete_custom_face'
|
||||
| 'delete_flash_file'
|
||||
| 'delete_qzone_msg'
|
||||
| 'delete_qzone_public_comment'
|
||||
| 'delete_qzone_public_reply'
|
||||
| 'do_group_album_comment'
|
||||
| 'download_file_image_stream'
|
||||
| 'download_file_record_stream'
|
||||
@@ -143,6 +200,7 @@ export type CoveredAction =
|
||||
| 'download_fileset'
|
||||
| 'fetch_custom_face_detail'
|
||||
| 'fetch_ptt_text'
|
||||
| 'forward_qzone_public_feed'
|
||||
| 'get_ptt_text'
|
||||
| 'get_record_text'
|
||||
| 'get_doubt_friends_add_request'
|
||||
@@ -158,6 +216,11 @@ export type CoveredAction =
|
||||
| 'get_qzone_feeds'
|
||||
| 'get_qzone_msg_list'
|
||||
| 'get_qzone_profile'
|
||||
| 'get_qzone_public_capabilities'
|
||||
| 'get_qzone_public_comments'
|
||||
| 'get_qzone_public_feed_detail'
|
||||
| 'get_qzone_public_feeds'
|
||||
| 'get_qzone_public_replies'
|
||||
| 'get_rkey_server'
|
||||
| 'get_share_link'
|
||||
| 'like_qzone'
|
||||
@@ -165,6 +228,7 @@ export type CoveredAction =
|
||||
| 'modify_custom_face'
|
||||
| 'move_custom_face_to_front'
|
||||
| 'rename_flash_file'
|
||||
| 'reply_qzone_public_feed'
|
||||
| 'request_decrypt_key'
|
||||
| 'send_ark_share'
|
||||
| 'send_flash_msg'
|
||||
@@ -180,6 +244,10 @@ export type CoveredAction =
|
||||
| 'set_qzone_ban'
|
||||
| 'set_qzone_msg_right'
|
||||
| 'set_qzone_profile'
|
||||
| 'set_qzone_public_follow'
|
||||
| 'set_qzone_public_comment_like'
|
||||
| 'set_qzone_public_like'
|
||||
| 'set_qzone_public_upvote'
|
||||
| 'share_group_ex'
|
||||
| 'share_peer'
|
||||
| 'test_download_stream'
|
||||
@@ -220,11 +288,14 @@ export const actionResults = {
|
||||
cancel_group_album_media_like: {},
|
||||
clean_stream_temp_file: { message: 'success', removed: 1, freed_bytes: 42, skipped_active: 1 },
|
||||
comment_qzone: { comment_id: 'comment' },
|
||||
comment_qzone_public_feed: { comment: qzonePublicComment },
|
||||
create_flash_task: { fileset_id: 'fileset', task_id: 'fileset' },
|
||||
del_group_album_media: { success: true },
|
||||
delete_custom_face: null,
|
||||
delete_flash_file: null,
|
||||
delete_qzone_msg: null,
|
||||
delete_qzone_public_comment: {},
|
||||
delete_qzone_public_reply: {},
|
||||
do_group_album_comment: {
|
||||
id: 'comment',
|
||||
user: { uin: '10002' },
|
||||
@@ -259,6 +330,7 @@ export const actionResults = {
|
||||
download_fileset: { url: '', file_name: 'file.txt', file_size: 42 },
|
||||
fetch_custom_face_detail: [{ emoji_id: 'face', resId: 'face', url: '', md5: '', desc: '' }],
|
||||
fetch_ptt_text: { text: 'Speech' },
|
||||
forward_qzone_public_feed: {},
|
||||
get_ptt_text: { text: 'Speech' },
|
||||
get_record_text: { text: 'Speech' },
|
||||
get_doubt_friends_add_request: [
|
||||
@@ -369,6 +441,28 @@ export const actionResults = {
|
||||
],
|
||||
},
|
||||
get_qzone_profile: { name: 'Space', description: 'Description' },
|
||||
get_qzone_public_capabilities: { public_qzone_entrance_switch: true, can_upvote: true },
|
||||
get_qzone_public_comments: {
|
||||
cell_comment: { comments: [qzonePublicComment] },
|
||||
attach_info: 'next-comments',
|
||||
has_more: true,
|
||||
},
|
||||
get_qzone_public_feed_detail: {
|
||||
feed: { feed: qzonePublicFeed },
|
||||
attach_info: 'comments-from-detail',
|
||||
has_more: true,
|
||||
},
|
||||
get_qzone_public_feeds: {
|
||||
feeds: [qzonePublicFeed],
|
||||
has_more: true,
|
||||
next_cursor: 'public-feed-cursor',
|
||||
unknown_page: { preserved: true },
|
||||
},
|
||||
get_qzone_public_replies: {
|
||||
replys: [qzonePublicReply],
|
||||
reply_attach_info: '',
|
||||
has_more: false,
|
||||
},
|
||||
get_rkey_server: { expired_time: 1, name: 'SnowLuma', private_rkey: 'fixture' },
|
||||
get_share_link: 'https://example.com/share',
|
||||
like_qzone: null,
|
||||
@@ -376,6 +470,7 @@ export const actionResults = {
|
||||
modify_custom_face: null,
|
||||
move_custom_face_to_front: null,
|
||||
rename_flash_file: null,
|
||||
reply_qzone_public_feed: { reply: qzonePublicReply },
|
||||
request_decrypt_key: { db_key: 'fixture' },
|
||||
send_ark_share: { arkMsg: '{}' },
|
||||
send_flash_msg: { message_id: 0 },
|
||||
@@ -391,6 +486,10 @@ export const actionResults = {
|
||||
set_qzone_ban: null,
|
||||
set_qzone_msg_right: { ugc_right: 128 },
|
||||
set_qzone_profile: null,
|
||||
set_qzone_public_follow: { ret_code: 0 },
|
||||
set_qzone_public_comment_like: { like: { status: 1 } },
|
||||
set_qzone_public_like: { like: { liked: true } },
|
||||
set_qzone_public_upvote: { upvote: { upvoted: true } },
|
||||
share_group_ex: '{}',
|
||||
share_peer: { arkMsg: '{}' },
|
||||
test_download_stream: {
|
||||
|
||||
+52
@@ -115,6 +115,58 @@ export const invalidQzoneProfilePatch: ActionParams<'set_qzone_profile'> = {
|
||||
// @ts-expect-error profile fields accept string, number or boolean primitives
|
||||
description: [],
|
||||
};
|
||||
const publicPage = await http.raw('get_qzone_public_feeds', {});
|
||||
export const publicCells: JsonObject[] = publicPage.feeds;
|
||||
export const publicHasMore: boolean = publicPage.has_more;
|
||||
export const publicCursor: string | null = publicPage.next_cursor;
|
||||
|
||||
if (publicPage.has_more && publicPage.next_cursor) {
|
||||
await http.raw('get_qzone_public_feeds', { cursor: publicPage.next_cursor });
|
||||
}
|
||||
|
||||
declare const publicFeed: JsonObject;
|
||||
declare const publicComment: JsonObject;
|
||||
export const publicReplyDefaults: ActionParams<'get_qzone_public_replies'> = {
|
||||
feed: publicFeed,
|
||||
comment: publicComment,
|
||||
};
|
||||
export const publicUpvoteDefault: ActionParams<'set_qzone_public_upvote'> = { feed: publicFeed };
|
||||
export const publicLikeDefault: ActionParams<'set_qzone_public_like'> = { feed: publicFeed };
|
||||
export const publicFollowDefault: ActionParams<'set_qzone_public_follow'> = { feed: publicFeed };
|
||||
export const publicCommentLikeDefault: ActionParams<'set_qzone_public_comment_like'> = {
|
||||
feed: publicFeed,
|
||||
comment: publicComment,
|
||||
};
|
||||
export const publicReplyLike: ActionParams<'set_qzone_public_comment_like'> = {
|
||||
feed: publicFeed,
|
||||
comment: publicComment,
|
||||
reply: { id: '18446744073709551615', like: { id: 'reply-like-key' } },
|
||||
enable: false,
|
||||
};
|
||||
export const publicReplyToComment: ActionParams<'reply_qzone_public_feed'> = {
|
||||
feed: publicFeed,
|
||||
comment: publicComment,
|
||||
content: 'Reply',
|
||||
};
|
||||
export const publicForwardDefault: ActionParams<'forward_qzone_public_feed'> = { feed: publicFeed };
|
||||
export const publicReplyResult: JsonObject = await ws.raw(
|
||||
'reply_qzone_public_feed',
|
||||
actionParams.reply_qzone_public_feed,
|
||||
);
|
||||
// @ts-expect-error follow-up comments require attach_info as the cursor
|
||||
export const publicCommentsWithoutCursor: ActionParams<'get_qzone_public_comments'> = {
|
||||
feed: publicFeed,
|
||||
};
|
||||
export const invalidPublicContent: ActionParams<'comment_qzone_public_feed'> = {
|
||||
feed: publicFeed,
|
||||
// @ts-expect-error public content does not coerce numeric primitives
|
||||
content: 123,
|
||||
};
|
||||
export const invalidPublicRichItems: ActionParams<'comment_qzone_public_feed'> = {
|
||||
feed: publicFeed,
|
||||
// @ts-expect-error rich-text arrays contain JSON objects, not strings
|
||||
content: ['text'],
|
||||
};
|
||||
const speech = await ws.raw('get_record_text', { message_id: -42 });
|
||||
const transcription: string = speech.text;
|
||||
const flash = await http.raw('get_fileset_info', { fileset_id: 'files' });
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { describe, expect, expectTypeOf, it, vi } from 'vitest';
|
||||
import { SnowLumaHttpClient, type JsonObject, type QzonePublicFeedsPage } from '../src';
|
||||
|
||||
const feed: JsonObject = {
|
||||
cell_common: {
|
||||
domain_type: 3,
|
||||
union_id: { uf_key: '9007199254740993', unknown_identity: 'preserved' },
|
||||
},
|
||||
cell_feed_transfer: { opaque: 'fixture' },
|
||||
unknown_cell: { decimal: '18446744073709551615' },
|
||||
};
|
||||
|
||||
describe('public Qzone raw actions', () => {
|
||||
it('preserves original feed cells and follows an explicit cursor after a short page', async () => {
|
||||
const first: QzonePublicFeedsPage = {
|
||||
feeds: [feed],
|
||||
has_more: true,
|
||||
next_cursor: 'account-bound-cursor',
|
||||
upstream_page: { untouched: '18446744073709551615' },
|
||||
};
|
||||
const last: QzonePublicFeedsPage = { feeds: [], has_more: false, next_cursor: null };
|
||||
const fetchImpl = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(
|
||||
async () => new Response(JSON.stringify({ status: 'ok', retcode: 0, data: first })),
|
||||
)
|
||||
.mockImplementationOnce(
|
||||
async () => new Response(JSON.stringify({ status: 'ok', retcode: 0, data: last })),
|
||||
);
|
||||
const client = new SnowLumaHttpClient({ fetch: fetchImpl });
|
||||
const page = await client.raw('get_qzone_public_feeds', {});
|
||||
|
||||
expectTypeOf(page).toEqualTypeOf<QzonePublicFeedsPage>();
|
||||
expect(page).toEqual(first);
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
||||
expect(page.has_more).toBe(true);
|
||||
expect(await client.raw('get_qzone_public_feeds', { cursor: page.next_cursor! })).toEqual(
|
||||
last,
|
||||
);
|
||||
expect(
|
||||
fetchImpl.mock.calls.map((call) => JSON.parse((call[1] as RequestInit).body as string)),
|
||||
).toEqual([
|
||||
{ action: 'get_qzone_public_feeds', params: {} },
|
||||
{ action: 'get_qzone_public_feeds', params: { cursor: 'account-bound-cursor' } },
|
||||
]);
|
||||
});
|
||||
|
||||
it('preserves complete comment and reply objects and unknown writer results', async () => {
|
||||
const comment: JsonObject = { id: '9007199254740993', unknown_parent: { keep: true } };
|
||||
const reply: JsonObject = { id: '18446744073709551615', user: { uid: 'reader' } };
|
||||
const content = [{ type: 0, content: 'Reply', upstream_option: true }];
|
||||
const data = { reply, upstream_result: { untouched: true } };
|
||||
const fetchImpl = vi
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
async () => new Response(JSON.stringify({ status: 'ok', retcode: 0, data })),
|
||||
);
|
||||
const client = new SnowLumaHttpClient({ fetch: fetchImpl });
|
||||
const params = { feed, comment, reply, content };
|
||||
const result = await client.raw('reply_qzone_public_feed', params);
|
||||
|
||||
expectTypeOf(result).toEqualTypeOf<JsonObject>();
|
||||
expect(result).toEqual(data);
|
||||
expect(fetchImpl).toHaveBeenCalledWith(
|
||||
'http://127.0.0.1:3000/',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({ action: 'reply_qzone_public_feed', params }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user