Feature(custom): support build-in lsky sync delete

This commit is contained in:
Kuingsmile 2024-01-02 01:37:53 -08:00
parent bbbfbda3e2
commit 4c032604c7
3 changed files with 44 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import DogeCloudApi from './dogecloud'
import HuaweicloudApi from './huaweiyun' import HuaweicloudApi from './huaweiyun'
import AlistApi from './alist' import AlistApi from './alist'
import PiclistApi from './piclist' import PiclistApi from './piclist'
import LskyplistApi from './lskyplist'
const apiMap: IStringKeyMap = { const apiMap: IStringKeyMap = {
aliyun: AliyunApi, aliyun: AliyunApi,
@ -29,7 +30,8 @@ const apiMap: IStringKeyMap = {
dogecloud: DogeCloudApi, dogecloud: DogeCloudApi,
'huaweicloud-uploader': HuaweicloudApi, 'huaweicloud-uploader': HuaweicloudApi,
alist: AlistApi, alist: AlistApi,
piclist: PiclistApi piclist: PiclistApi,
lskyplist: LskyplistApi
} }
export default class ALLApi { export default class ALLApi {

View File

@ -0,0 +1,39 @@
import axios, { AxiosResponse } from 'axios'
import https from 'https'
export default class LskyplistApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { hash, config } = configMap
if (!hash || !config || !config.token) {
console.error('LskyplistApi.delete: invalid params')
return false
}
const { host, token, version } = config
if (version !== 'V2') {
console.error('LskyplistApi.delete: invalid version')
return false
}
const v2Headers = {
Accept: 'application/json',
Authorization: token || undefined
}
const requestAgent = new https.Agent({
rejectUnauthorized: false
})
try {
const response: AxiosResponse = await axios.delete(
`${host}/api/v1/images/${hash}`, {
headers: v2Headers,
timeout: 30000,
httpsAgent: requestAgent
})
return response.status === 200 && response.data.status === true
} catch (error) {
console.error(error)
return false
}
}
}

View File

@ -21,5 +21,6 @@ export const picBedsCanbeDeleted = [
'dogecloud', 'dogecloud',
'huaweicloud-uploader', 'huaweicloud-uploader',
'alist', 'alist',
'piclist' 'piclist',
'lskyplist'
] ]