mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-18 10:03:55 +00:00

* add admin audit (#5041) * Test audit (#5058) * feat: operation index * fix: delete update vector * perf: Clear invalid data * perf: index * perf: cleare invalid data * index * perf: audit event * fix: schema enum * add audit.svg (#5060) Co-authored-by: dreamer6680 <146868355@qq.com> * update package * perf: audit * perf: code move * eslint * doc --------- Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com> Co-authored-by: dreamer6680 <1468683855@qq.com> Co-authored-by: dreamer6680 <146868355@qq.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { MongoOutLink } from '@fastgpt/service/support/outLink/schema';
|
|
import { authOutLinkCrud } from '@fastgpt/service/support/permission/publish/authLink';
|
|
import { OwnerPermissionVal } from '@fastgpt/global/support/permission/constant';
|
|
import type { ApiRequestProps } from '@fastgpt/service/type/next';
|
|
import { NextAPI } from '@/service/middleware/entry';
|
|
import { addAuditLog } from '@fastgpt/service/support/user/audit/util';
|
|
import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants';
|
|
import { getI18nAppType } from '@fastgpt/service/support/user/audit/util';
|
|
|
|
export type OutLinkDeleteQuery = {
|
|
id: string;
|
|
};
|
|
export type OutLinkDeleteBody = {};
|
|
export type OutLinkDeleteResponse = {};
|
|
|
|
/* delete a shareChat by shareChatId */
|
|
async function handler(
|
|
req: ApiRequestProps<OutLinkDeleteBody, OutLinkDeleteQuery>
|
|
): Promise<OutLinkDeleteResponse> {
|
|
const { id } = req.query;
|
|
const { tmbId, teamId, outLink, app } = await authOutLinkCrud({
|
|
req,
|
|
outLinkId: id,
|
|
authToken: true,
|
|
per: OwnerPermissionVal
|
|
});
|
|
|
|
await MongoOutLink.findByIdAndDelete(id);
|
|
|
|
(async () => {
|
|
addAuditLog({
|
|
tmbId,
|
|
teamId,
|
|
event: AuditEventEnum.DELETE_APP_PUBLISH_CHANNEL,
|
|
params: {
|
|
appName: app.name,
|
|
channelName: outLink.name,
|
|
appType: getI18nAppType(app.type)
|
|
}
|
|
});
|
|
})();
|
|
|
|
return {};
|
|
}
|
|
|
|
export default NextAPI(handler);
|