feat(qzone): add homepage feeds and share cards
Read accessible Qzone homepage posts and generate their original share cards. Return sharing notices so callers can confirm visibility before sending through the existing message actions. Include SDK contracts, action discovery, documentation, and regression coverage. Fixes #609
This commit is contained in:
15 files changed
+944
-4
No files matched your search
@@ -96,6 +96,8 @@ export const actionParams = {
|
||||
get_qzone_msg_list: { target_uin: '10002', pos: '0', num: '20' },
|
||||
get_qzone_profile: { target_uin: '10002' },
|
||||
get_qzone_public_capabilities: {},
|
||||
get_qzone_home_feeds: { target_uin: '10001', cursor: 'home-feed-cursor' },
|
||||
get_qzone_share_ark: { feed: qzonePublicFeed },
|
||||
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' },
|
||||
@@ -229,6 +231,8 @@ export type CoveredAction =
|
||||
| 'get_qzone_msg_list'
|
||||
| 'get_qzone_profile'
|
||||
| 'get_qzone_public_capabilities'
|
||||
| 'get_qzone_home_feeds'
|
||||
| 'get_qzone_share_ark'
|
||||
| 'get_qzone_public_comments'
|
||||
| 'get_qzone_public_feed_detail'
|
||||
| 'get_qzone_public_feeds'
|
||||
@@ -464,6 +468,8 @@ export const actionResults = {
|
||||
},
|
||||
get_qzone_profile: { name: 'Space', description: 'Description' },
|
||||
get_qzone_public_capabilities: { public_qzone_entrance_switch: true, can_upvote: true },
|
||||
get_qzone_home_feeds: { feeds: [qzonePublicFeed], has_more: false, next_cursor: null },
|
||||
get_qzone_share_ark: { ark: '{"app":"com.tencent.tuwen.lua"}', requires_confirmation: false, notice: null },
|
||||
get_qzone_public_comments: {
|
||||
cell_comment: { comments: [qzonePublicComment] },
|
||||
attach_info: 'next-comments',
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { describe, expect, expectTypeOf, it, vi } from 'vitest';
|
||||
import { SnowLumaHttpClient, type JsonObject, type QzonePublicFeedsPage } from '../src';
|
||||
import {
|
||||
SnowLumaHttpClient,
|
||||
type JsonObject,
|
||||
type QzonePublicFeedsPage,
|
||||
type QzoneShareArkResult,
|
||||
} from '../src';
|
||||
|
||||
const feed: JsonObject = {
|
||||
cell_common: {
|
||||
@@ -11,6 +16,33 @@ const feed: JsonObject = {
|
||||
};
|
||||
|
||||
describe('public Qzone raw actions', () => {
|
||||
it('exposes homepage and card types without automatically sending the card', async () => {
|
||||
const page: QzonePublicFeedsPage = { feeds: [feed], has_more: false, next_cursor: null };
|
||||
const card: QzoneShareArkResult = {
|
||||
ark: '{ "app": "com.tencent.tuwen.lua" }',
|
||||
requires_confirmation: true,
|
||||
notice: '所有人可见',
|
||||
};
|
||||
const fetchImpl = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify({ status: 'ok', retcode: 0, data: page })),
|
||||
)
|
||||
.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify({ status: 'ok', retcode: 0, data: card })),
|
||||
);
|
||||
const client = new SnowLumaHttpClient({ fetch: fetchImpl });
|
||||
const homepage = await client.raw('get_qzone_home_feeds', {});
|
||||
expectTypeOf(homepage).toEqualTypeOf<QzonePublicFeedsPage>();
|
||||
const result = await client.raw('get_qzone_share_ark', { feed: homepage.feeds[0]! });
|
||||
expectTypeOf(result).toEqualTypeOf<QzoneShareArkResult>();
|
||||
expect(result).toEqual(card);
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
||||
expect(JSON.parse(fetchImpl.mock.calls[1]![1].body)).toEqual({
|
||||
action: 'get_qzone_share_ark',
|
||||
params: { feed },
|
||||
});
|
||||
});
|
||||
it('preserves original feed cells and follows an explicit cursor after a short page', async () => {
|
||||
const first: QzonePublicFeedsPage = {
|
||||
feeds: [feed],
|
||||
|
||||
Reference in new issue
Block a user