app list open-api & completion with appid & get history source (#3011)

* app list open-api & completion with appid & get history source

* change default value position
This commit is contained in:
heheer
2024-10-29 14:27:29 +08:00
committed by GitHub
parent efc4e860b7
commit 98771284e4
5 changed files with 21 additions and 6 deletions

View File

@@ -39,6 +39,7 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
return await authApp({
req,
authToken: true,
authApiKey: true,
appId: parentId,
per: ReadPermissionVal
});
@@ -47,6 +48,7 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
...(await authUserPer({
req,
authToken: true,
authApiKey: true,
per: ReadPermissionVal
})),
app: undefined

View File

@@ -17,8 +17,16 @@ async function handler(
req: ApiRequestProps<getHistoriesBody, getHistoriesQuery>,
res: ApiResponseType<any>
): Promise<PaginationResponse<getHistoriesResponse>> {
const { appId, shareId, outLinkUid, teamId, teamToken, offset, pageSize } =
req.body as getHistoriesBody;
const {
appId,
shareId,
outLinkUid,
teamId,
teamToken,
offset,
pageSize,
source = ChatSourceEnum.online
} = req.body as getHistoriesBody;
const match = await (async () => {
if (shareId && outLinkUid) {
@@ -47,7 +55,7 @@ async function handler(
return {
tmbId,
appId,
source: ChatSourceEnum.online
source: source
};
}
})();

View File

@@ -536,12 +536,13 @@ const authHeaderRequest = async ({
const { app } = await (async () => {
if (authType === AuthUserTypeEnum.apikey) {
if (!apiKeyAppId) {
const currentAppId = apiKeyAppId || appId;
if (!currentAppId) {
return Promise.reject(
'Key is error. You need to use the app key rather than the account key.'
);
}
const app = await MongoApp.findById(apiKeyAppId);
const app = await MongoApp.findById(currentAppId);
if (!app) {
return Promise.reject('app is empty');