mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
build: 1.3.5-beta33
This commit is contained in:
parent
44974034ec
commit
c3f3d12f83
@ -9,7 +9,7 @@ import Ajv from 'ajv';
|
|||||||
interface FileResponse {
|
interface FileResponse {
|
||||||
file: string;
|
file: string;
|
||||||
}
|
}
|
||||||
const PayloadSchema = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
thread_count: { type: 'number' },
|
thread_count: { type: 'number' },
|
||||||
@ -17,7 +17,7 @@ const PayloadSchema = {
|
|||||||
base64: { type: 'string' },
|
base64: { type: 'string' },
|
||||||
name: { type: 'string' },
|
name: { type: 'string' },
|
||||||
headers: {
|
headers: {
|
||||||
type: "array",
|
type: ["string", "array"],
|
||||||
items: {
|
items: {
|
||||||
type: "string"
|
type: "string"
|
||||||
}
|
}
|
||||||
@ -25,22 +25,11 @@ const PayloadSchema = {
|
|||||||
},
|
},
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof PayloadSchema>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileResponse> {
|
export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileResponse> {
|
||||||
actionName = ActionName.GoCQHTTP_DownloadFile;
|
actionName = ActionName.GoCQHTTP_DownloadFile;
|
||||||
validateDownload = new Ajv().compile(PayloadSchema);
|
PayloadSchema = SchemaData;
|
||||||
// 这里重写是为了兼容 headers可能出现 string string[]
|
|
||||||
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
|
||||||
if (payload.headers) {
|
|
||||||
// 如果存在headers 为数组则开始兼容string string[]
|
|
||||||
payload.headers = payload?.headers && Array.isArray(payload.headers) ? payload.headers : [payload.headers as unknown as string];
|
|
||||||
}
|
|
||||||
if (!this.validateDownload(payload)) {
|
|
||||||
return { valid: false, message: this.validateDownload.errors?.map(e => e.message).join(', ') as string };
|
|
||||||
}
|
|
||||||
return { valid: true };
|
|
||||||
}
|
|
||||||
protected async _handle(payload: Payload): Promise<FileResponse> {
|
protected async _handle(payload: Payload): Promise<FileResponse> {
|
||||||
const isRandomName = !payload.name;
|
const isRandomName = !payload.name;
|
||||||
const name = payload.name || uuid4();
|
const name = payload.name || uuid4();
|
||||||
|
@ -11,7 +11,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
no_cache: { type: 'boolean' },
|
no_cache: { type: ['boolean', 'string'] },
|
||||||
}
|
}
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
|||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
let groupList: Group[] = Array.from(groups.values());
|
let groupList: Group[] = Array.from(groups.values());
|
||||||
if (groupList.length === 0 || payload?.no_cache === true /*|| payload.no_cache === 'true'*/) {
|
if (groupList.length === 0 || payload?.no_cache === true || payload.no_cache === 'true') {
|
||||||
groupList = await NTQQGroupApi.getGroups(true);
|
groupList = await NTQQGroupApi.getGroups(true);
|
||||||
// log('get groups', groups);
|
// log('get groups', groups);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ const SchemaData = {
|
|||||||
properties: {
|
properties: {
|
||||||
group_id: { type: 'number' },
|
group_id: { type: 'number' },
|
||||||
user_id: { type: 'number' },
|
user_id: { type: 'number' },
|
||||||
no_cache: { type: 'boolean' },
|
no_cache: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'user_id']
|
required: ['group_id', 'user_id']
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
@ -11,7 +11,7 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: 'number' },
|
group_id: { type: 'number' },
|
||||||
no_cache: { type: 'boolean' },
|
no_cache: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'user_id']
|
required: ['group_id', 'user_id']
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -28,7 +28,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
if (!group) {
|
if (!group) {
|
||||||
throw (`群${payload.group_id}不存在`);
|
throw (`群${payload.group_id}不存在`);
|
||||||
}
|
}
|
||||||
if (payload.no_cache == true /*|| payload.no_cache === 'true'*/) {
|
if (payload.no_cache == true || payload.no_cache === 'true') {
|
||||||
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||||
groupMembers.set(group.groupCode, _groupMembers);
|
groupMembers.set(group.groupCode, _groupMembers);
|
||||||
|
@ -11,7 +11,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
no_cache: { type: 'boolean' },
|
no_cache: { type: ['boolean', 'string'] },
|
||||||
}
|
}
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|||||||
actionName = ActionName.GetFriendList;
|
actionName = ActionName.GetFriendList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
if (friends.size === 0 || payload?.no_cache === true /*|| payload?.no_cache === 'true'*/) {
|
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
||||||
const _friends = await NTQQFriendApi.getFriends(true);
|
const _friends = await NTQQFriendApi.getFriends(true);
|
||||||
// log('强制刷新好友列表,结果: ', _friends)
|
// log('强制刷新好友列表,结果: ', _friends)
|
||||||
if (_friends.length > 0) {
|
if (_friends.length > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user