40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import Wechat from './wechat';
|
|
import WechatSDK from 'oak-external-sdk/lib/WechatSDK';
|
|
import { assert } from 'oak-domain/lib/utils/assert';
|
|
export default class WechatBackend extends Wechat {
|
|
getConfigAndInstance(application) {
|
|
const { config, type } = this.getConfig(application);
|
|
return {
|
|
config,
|
|
type,
|
|
};
|
|
}
|
|
async composeFileUrlBackend(options) {
|
|
const { application, extraFile, context, style } = options;
|
|
return '';
|
|
}
|
|
async formUploadMeta(application, extraFile) {
|
|
// 微信上传素材库
|
|
}
|
|
async checkWhetherSuccess(application, extraFile) {
|
|
const { extra1 } = extraFile;
|
|
return !!extra1;
|
|
}
|
|
async removeFile(application, extraFile) {
|
|
const { extra2, extra1: mediaId } = extraFile;
|
|
const isPermanent = extra2?.isPermanent || false;
|
|
const { config, type } = this.getConfigAndInstance(application);
|
|
// 只有永久素材 才能删除素材
|
|
if (isPermanent) {
|
|
assert(mediaId);
|
|
const { appId, appSecret } = config;
|
|
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
|
|
const result = await wechatInstance.deleteMaterial({
|
|
mediaId,
|
|
});
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
;
|