Skip to content

Commit 41e2861

Browse files
Joy-Wangjoyqwang
andauthored
新增机器人获取表情表态成员列表接口 (#70)
* feat: 新增机器人获取表情表态成员列表接口 Co-authored-by: joyqwang <[email protected]>
1 parent fd053d5 commit 41e2861

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

src/openapi/v1/reaction.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config, OpenAPIRequest, ReactionAPI, ReactionObj } from '@src/types';
1+
import { Config, OpenAPIRequest, ReactionAPI, ReactionObj, ReactionUserListObj } from '@src/types';
22
import { RestyResponse } from 'resty-client';
33
import { getURL } from './resource';
44

@@ -39,4 +39,28 @@ export default class Reaction implements ReactionAPI {
3939
};
4040
return this.request(options);
4141
}
42+
43+
// 拉取表情表态用户列表
44+
public getReactionUserList(
45+
channelId: string,
46+
reactionToCreate: ReactionObj,
47+
options: ReactionUserListObj,
48+
): Promise<RestyResponse<any>> {
49+
if (!options) {
50+
return Promise.reject(new Error("'options' required!"));
51+
}
52+
53+
const reqOptions = {
54+
method: 'GET' as const,
55+
url: getURL('reactionURI'),
56+
rest: {
57+
channelID: channelId,
58+
messageID: reactionToCreate?.message_id,
59+
emojiType: reactionToCreate?.emoji_type,
60+
emojiID: reactionToCreate?.emoji_id,
61+
},
62+
params: options,
63+
};
64+
return this.request(reqOptions);
65+
}
4266
}

src/types/openapi/v1/reaction.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ import { RestyResponse } from 'resty-client';
66
export interface ReactionAPI {
77
postReaction: (channelID: string, reactionToCreate: ReactionObj) => Promise<RestyResponse<any>>;
88
deleteReaction: (channelID: string, reactionToDelete: ReactionObj) => Promise<RestyResponse<any>>;
9+
getReactionUserList: (
10+
channelID: string,
11+
reactionToDelete: ReactionObj,
12+
options: ReactionUserListObj,
13+
) => Promise<RestyResponse<any>>;
914
}
1015

1116
export interface ReactionObj {
1217
message_id: string;
1318
emoji_type: number;
1419
emoji_id: string;
1520
}
21+
22+
// 拉取表情表态用户列表分页入参
23+
export interface ReactionUserListObj {
24+
cookie: string; // 上次请求返回的cookie,第一次请求无需填写
25+
limit: number; // 每次拉取数量,默认20,最多50,只在第一次请求时设置
26+
}

test/openapi/v1/reaction.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { client, channelID, REQUEST_SUCCESS_CODE_WITH_NO_CONTENT } from '../config';
2+
3+
describe('reaction测试', () => {
4+
const messageID = '1'
5+
const emojiType = 1;
6+
const emojiID = '1';
7+
const cookie = '';
8+
const limit = 20;
9+
10+
test('【 postReaction方法 】=== 发表表情表态', async () => {
11+
// 发表表情表态
12+
const params = {
13+
message_id: messageID,
14+
emoji_type: emojiType,
15+
emoji_id: emojiID
16+
}
17+
const reactionRes = (await client.reactionApi.postReaction(channelID, params)).data;
18+
expect(reactionRes?.status).toStrictEqual(REQUEST_SUCCESS_CODE_WITH_NO_CONTENT);
19+
});
20+
21+
test('【 deleteReaction方法 】=== 删除表情表态', async () => {
22+
// 删除表情表态
23+
const params = {
24+
message_id: messageID,
25+
emoji_type: emojiType,
26+
emoji_id: emojiID
27+
}
28+
const reactionRes = (await client.reactionApi.deleteReaction(channelID, params)).data;
29+
expect(reactionRes?.status).toStrictEqual(REQUEST_SUCCESS_CODE_WITH_NO_CONTENT);
30+
});
31+
32+
test('【 getReactionUserList方法 】=== 拉取表情表态用户列表', async () => {
33+
// 拉取表情表态用户列表
34+
const params = {
35+
message_id: messageID,
36+
emoji_type: emojiType,
37+
emoji_id: emojiID
38+
}
39+
const options = {
40+
cookie,
41+
limit
42+
}
43+
const reactionRes = (await client.reactionApi.getReactionUserList(channelID, params, options)).data;
44+
expect(reactionRes?.status).toStrictEqual(REQUEST_SUCCESS_CODE_WITH_NO_CONTENT);
45+
});
46+
});

0 commit comments

Comments
 (0)