feat: 重构消息发送部分,支持消息类型处理器注入
This commit is contained in:
parent
f57dacfe5d
commit
5fbc76c93f
|
|
@ -329,7 +329,7 @@ export async function authorize(params, context) {
|
|||
applicationId: context.getApplicationId(),
|
||||
userId: context.getCurrentUserId(),
|
||||
scope: scope === undefined ? [] : [scope],
|
||||
expiresAt: Date.now() + 10 * 60 * 1000,
|
||||
expiresAt: Date.now() + 10 * 60 * 1000, // 10分钟后过期
|
||||
// PKCE 支持
|
||||
codeChallenge: code_challenge,
|
||||
codeChallengeMethod: code_challenge_method || 'plain',
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'image',
|
||||
tag1: 'image',
|
||||
objectId: await generateNewIdAsync(),
|
||||
objectId: await generateNewIdAsync(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
@ -128,7 +128,7 @@ export async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'video',
|
||||
tag1: 'video',
|
||||
objectId: await generateNewIdAsync(),
|
||||
objectId: await generateNewIdAsync(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
@ -150,7 +150,7 @@ export async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'audio',
|
||||
tag1: 'audio',
|
||||
objectId: await generateNewIdAsync(),
|
||||
objectId: await generateNewIdAsync(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ export async function createWechatQrCode(options, context) {
|
|||
permanent,
|
||||
url,
|
||||
expired: false,
|
||||
expiresAt: Date.now() + 2592000 * 1000,
|
||||
expiresAt: Date.now() + 2592000 * 1000, // wecharQrCode里的过期时间都放到最大,由上层关联对象来主动过期(by Xc, 20230131)
|
||||
props,
|
||||
};
|
||||
// 直接创建
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ export default OakComponent({
|
|||
properties: {
|
||||
articleMenuId: '',
|
||||
changeIsEdit: () => undefined,
|
||||
tocPosition: 'none',
|
||||
highlightBgColor: 'none',
|
||||
onArticlePreview: (content, title) => undefined,
|
||||
origin: null,
|
||||
scrollId: '',
|
||||
tocPosition: 'none', //目录显示位置,none为不显示目录
|
||||
highlightBgColor: 'none', //点击目录时标题高亮背景色,none为不显示高亮背景色
|
||||
onArticlePreview: (content, title) => undefined, //预览文章
|
||||
origin: null, // 默认为空,由系统决定
|
||||
scrollId: '', // 滚动条所在容器id,不传默认页面编辑器容器id
|
||||
height: 600,
|
||||
activeColor: undefined,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ export default OakComponent({
|
|||
tocFixed: true,
|
||||
tocPosition: 'none',
|
||||
highlightBgColor: 'none',
|
||||
headerTop: 0,
|
||||
headerTop: 0, //页面中吸顶部分高度
|
||||
className: '',
|
||||
scrollId: '',
|
||||
scrollId: '', // 滚动条所在容器id,不传默认body
|
||||
tocWidth: undefined,
|
||||
tocHeight: undefined,
|
||||
showtitle: false,
|
||||
showtitle: false, //大纲顶层显示文章名称
|
||||
activeColor: undefined,
|
||||
},
|
||||
methods: {},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export default OakComponent({
|
|||
properties: {
|
||||
articleMenuId: '',
|
||||
onChildEditArticleChange: (data) => undefined,
|
||||
show: 'edit',
|
||||
show: 'edit', // edit为编辑,doc为查看,preview为预览
|
||||
getBreadcrumbItemsByParent: (breadcrumbItems) => undefined,
|
||||
breadcrumbItems: [],
|
||||
drawerOpen: false,
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ export default OakComponent({
|
|||
properties: {
|
||||
articleMenuId: '',
|
||||
changeIsEdit: () => undefined,
|
||||
tocPosition: 'none',
|
||||
highlightBgColor: 'none',
|
||||
onArticlePreview: (content, title) => undefined,
|
||||
origin: null,
|
||||
scrollId: '',
|
||||
tocPosition: 'none', //目录显示位置,none为不显示目录
|
||||
highlightBgColor: 'none', //点击目录时标题高亮背景色,none为不显示高亮背景色
|
||||
onArticlePreview: (content, title) => undefined, //预览文章
|
||||
origin: null, // 默认为七牛云
|
||||
scrollId: '', // 滚动条所在容器id,不传默认页面编辑器容器id
|
||||
height: 600,
|
||||
activeColor: undefined,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export default OakComponent({
|
|||
};
|
||||
},
|
||||
properties: {
|
||||
highlightBgColor: 'none',
|
||||
highlightBgColor: 'none', //点击文章目录时标题高亮背景色,none为不显示高亮背景色
|
||||
allowHiddenMenu: false,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export default OakComponent({
|
|||
onRemove: () => undefined,
|
||||
onUpdateName: async (name) => undefined,
|
||||
onChildEditArticleChange: (data) => undefined,
|
||||
show: 'edit',
|
||||
show: 'edit', // edit为编辑,doc为查看,preview为预览
|
||||
getBreadcrumbItemsByParent: (breadcrumbItems) => undefined,
|
||||
breadItems: [],
|
||||
drawerOpen: false,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export default OakComponent({
|
|||
entityId: '',
|
||||
parentId: '',
|
||||
onGrandChildEditArticleChange: (data) => undefined,
|
||||
show: 'edit',
|
||||
show: 'edit', // edit为编辑,doc为查看,preview为预览
|
||||
articleMenuId: '',
|
||||
articleId: '',
|
||||
getBreadcrumbItems: (breadcrumbItems) => undefined,
|
||||
|
|
|
|||
|
|
@ -14,19 +14,19 @@ export default OakComponent({
|
|||
properties: {
|
||||
entity: '',
|
||||
entityId: '',
|
||||
show: 'edit',
|
||||
articleMenuId: '',
|
||||
articleId: '',
|
||||
tocPosition: 'none',
|
||||
highlightBgColor: 'none',
|
||||
onMenuView: () => undefined,
|
||||
onMenuViewById: (articleMenuId) => undefined,
|
||||
onArticleView: (articleId) => undefined,
|
||||
onArticlePreview: (content, title) => undefined,
|
||||
onArticleEdit: (articleId) => undefined,
|
||||
show: 'edit', // edit为编辑,doc为查看,preview为预览
|
||||
articleMenuId: '', // 菜单id
|
||||
articleId: '', //文章id
|
||||
tocPosition: 'none', //文章目录显示位置,none为不显示目录
|
||||
highlightBgColor: 'none', //点击文章目录时标题高亮背景色,none为不显示高亮背景色
|
||||
onMenuView: () => undefined, //查看全部菜单
|
||||
onMenuViewById: (articleMenuId) => undefined, //查看指定id菜单
|
||||
onArticleView: (articleId) => undefined, //查看文章
|
||||
onArticlePreview: (content, title) => undefined, //预览文章
|
||||
onArticleEdit: (articleId) => undefined, //编辑文章
|
||||
setCopyArticleUrl: (articleId) => '',
|
||||
origin: null,
|
||||
scrollId: '',
|
||||
origin: null, // cos origin默认由系统决定
|
||||
scrollId: '', // 滚动条所在容器id,不传默认页面编辑器容器id
|
||||
activeColor: undefined, //目录高亮颜色
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export default OakComponent({
|
|||
code: '',
|
||||
title: '',
|
||||
desc: '',
|
||||
icon: '',
|
||||
icon: '', //web独有
|
||||
imagePath: '', //小程序独有
|
||||
},
|
||||
lifetimes: {
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ export default OakComponent({
|
|||
return;
|
||||
}
|
||||
const qrCodeURL = qrcode.drawImg(url, {
|
||||
typeNumber: 4,
|
||||
errorCorrectLevel: 'L',
|
||||
size: size,
|
||||
typeNumber: 4, // 密度
|
||||
errorCorrectLevel: 'L', // 纠错等级
|
||||
size: size, // 白色边框
|
||||
color,
|
||||
bgColor
|
||||
});
|
||||
|
|
@ -77,8 +77,8 @@ export default OakComponent({
|
|||
// 注意:写入前需确保Base64数据已经去掉了数据URL前缀(如"data:image/png;base64,")
|
||||
fs.writeFile({
|
||||
filePath: filePath,
|
||||
data: base64Data,
|
||||
encoding: 'base64',
|
||||
data: base64Data, // 传入纯Base64字符串
|
||||
encoding: 'base64', // 指定编码格式
|
||||
success(res) {
|
||||
// 文件写入成功后,检查并保存到相册
|
||||
that.checkAuthAndSave(filePath);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export default OakComponent({
|
|||
color: '#666',
|
||||
selectedColor: '',
|
||||
border: false,
|
||||
selectedIconPath: '',
|
||||
selectedIconPath: '', //一般在list设置
|
||||
iconPath: '',
|
||||
},
|
||||
lifetimes: {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export default function render(props) {
|
|||
};
|
||||
return (<>
|
||||
{enableCrop ? (<ImgCrop showReset={showRest} showGrid={showGrid} fillColor={fillColor} rotationSlider={rotationSlider} aspectSlider={aspectSlider} zoomSlider={zoomSlider} resetText={resetText} aspect={aspect} minZoom={minZoom} maxZoom={maxZoom} cropShape={cropShape} quality={cropQuality} cropperProps={{
|
||||
restrictPosition: false,
|
||||
restrictPosition: false, //允许移动图片位置
|
||||
...cropperProps,
|
||||
}} modalTitle={modalTitle} modalWidth={modalWidth} modalOk={modalOk} modalCancel={modalCancel}>
|
||||
<ExtrafileUpload oakPath={oakFullpath} bucket={bucket} autoUpload={autoUpload} maxNumber={maxNumber} mode={mode} showUploadList={showUploadList} showUploadProgress={showUploadProgress} accept={accept} disablePreview={disablePreview} disableDelete={disableDelete} disableAdd={disableAdd} disableDownload={disableDownload} disabled={disabled} type={type} origin={origin} tag1={tag1} tag2={tag2} entity={entity} entityId={entityId} theme={theme} children={children} beforeUpload={async (file) => {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
size: number;
|
||||
showUploadList: boolean;
|
||||
showUploadProgress: boolean;
|
||||
calcMd5: boolean;
|
||||
accept: string;
|
||||
disablePreview: boolean;
|
||||
disableDelete: boolean;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
import { assert } from 'oak-domain/lib/utils/assert';
|
||||
import { calculateFileMd5 } from '../../../utils/files/md5';
|
||||
;
|
||||
export default OakComponent({
|
||||
entity: 'extraFile',
|
||||
|
|
@ -59,6 +60,7 @@ export default OakComponent({
|
|||
size: 3, // 每行可显示的个数 小程序独有
|
||||
showUploadList: true, //web独有
|
||||
showUploadProgress: false, // web独有
|
||||
calcMd5: false, // 是否计算文件md5值
|
||||
accept: 'image/*', // web独有
|
||||
disablePreview: false, // 图片是否可预览
|
||||
disableDelete: false, // 图片是否可删除
|
||||
|
|
@ -136,7 +138,7 @@ export default OakComponent({
|
|||
async addExtraFileInner(options, file) {
|
||||
const { type, origin, // 默认由系统决定
|
||||
tag1, tag2, entity, entityId, bucket, autoUpload, } = this.props;
|
||||
const { name, fileType, size, sort } = options;
|
||||
const { name, fileType, size, sort, md5 } = options;
|
||||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
const { files } = this.state;
|
||||
|
|
@ -152,6 +154,7 @@ export default OakComponent({
|
|||
entity,
|
||||
filename,
|
||||
size,
|
||||
md5,
|
||||
extension,
|
||||
fileType,
|
||||
entityId,
|
||||
|
|
@ -168,12 +171,26 @@ export default OakComponent({
|
|||
this.features.extraFile.addLocalFile(id, file);
|
||||
}
|
||||
},
|
||||
addFileByWeb(file) {
|
||||
async addFileByWeb(file) {
|
||||
const { size, type, name } = file;
|
||||
this.addExtraFileInner({
|
||||
let md5 = null;
|
||||
if (this.props.calcMd5) {
|
||||
try {
|
||||
// 计算文件md5值
|
||||
md5 = await calculateFileMd5(file);
|
||||
}
|
||||
catch (error) {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: '计算文件MD5失败',
|
||||
});
|
||||
}
|
||||
}
|
||||
await this.addExtraFileInner({
|
||||
name,
|
||||
fileType: type,
|
||||
size,
|
||||
md5,
|
||||
sort: this.getSort(),
|
||||
}, file);
|
||||
},
|
||||
|
|
@ -194,17 +211,30 @@ export default OakComponent({
|
|||
});
|
||||
}
|
||||
else {
|
||||
tempFiles.map((tempExtraFile, index) => {
|
||||
await Promise.all(tempFiles.map(async (tempExtraFile, index) => {
|
||||
const { tempFilePath, thumbTempFilePath, fileType, size, } = tempExtraFile;
|
||||
const filePath = tempFilePath || thumbTempFilePath;
|
||||
const fileFullName = filePath.match(/[^/]+(?!.*\/)/g)[0];
|
||||
this.addExtraFileInner({
|
||||
let md5 = null;
|
||||
if (this.props.calcMd5) {
|
||||
try {
|
||||
md5 = await calculateFileMd5(filePath);
|
||||
}
|
||||
catch (error) {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: '计算文件MD5失败',
|
||||
});
|
||||
}
|
||||
}
|
||||
await this.addExtraFileInner({
|
||||
name: fileFullName,
|
||||
fileType,
|
||||
size,
|
||||
md5,
|
||||
sort: this.getSort(index),
|
||||
}, filePath);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ export default OakComponent({
|
|||
name: 1,
|
||||
description: 1,
|
||||
redirectUris: 1,
|
||||
logo: 1,
|
||||
logo: 1, // string
|
||||
isConfidential: 1,
|
||||
scopes: 1,
|
||||
scopes: 1, // string[]
|
||||
ableState: 1,
|
||||
requirePKCE: 1,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export default OakComponent({
|
|||
properties: {
|
||||
sessionId: '',
|
||||
isEntity: false,
|
||||
entityDisplay: (data) => [],
|
||||
entityDisplay: (data) => [], // user端,指示如何显示entity对象名称
|
||||
entityProjection: null, // user端,指示需要取哪些entity的属性来显示entityDisplay
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export default OakComponent({
|
|||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
type: 1,
|
||||
type: 1, //类型
|
||||
ticket: 1,
|
||||
url: 1,
|
||||
buffer: 1,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export default OakComponent({
|
|||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
type: 1,
|
||||
type: 1, //类型
|
||||
ticket: 1,
|
||||
url: 1,
|
||||
buffer: 1,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export default OakComponent({
|
|||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
type: 1,
|
||||
type: 1, //类型
|
||||
ticket: 1,
|
||||
url: 1,
|
||||
expired: 1,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export default OakComponent({
|
|||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
type: 1,
|
||||
type: 1, //类型
|
||||
ticket: 1,
|
||||
url: 1,
|
||||
buffer: 1,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ export const entityDesc = {
|
|||
zh_CN: {
|
||||
name: '直播流',
|
||||
attr: {
|
||||
title: '名称',
|
||||
title: '名称', // 用户定义直播间名称,
|
||||
streamTitle: '直播流名称',
|
||||
liveonly: '活跃状态',
|
||||
hub: '直播空间名称',
|
||||
hub: '直播空间名称', // 所属直播空间名称
|
||||
entity: '所属实体',
|
||||
entityId: '所属实体id',
|
||||
rtmpPushUrl: '推流地址',
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ export {
|
|||
*/
|
||||
registerMessageType, } from './aspects/template';
|
||||
export { registerWeChatPublicEventCallback, } from './endpoints/wechat';
|
||||
export { registerMessageNotificationConverters, } from './triggers/message';
|
||||
export { registerMessageNotificationConverters, registerMessageHandler, } from './utils/message';
|
||||
export { registSms, } from './utils/sms';
|
||||
export { registerCosBackend, } from './utils/cos/index.backend';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export {
|
|||
registerWeChatPublicEventCallback, } from './endpoints/wechat';
|
||||
export {
|
||||
// 注册消息通知转换器trigger
|
||||
registerMessageNotificationConverters, } from './triggers/message';
|
||||
registerMessageNotificationConverters, registerMessageHandler, } from './utils/message';
|
||||
export {
|
||||
// 注册短信服务商实现
|
||||
registSms, } from './utils/sms';
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthApplication", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthProvider", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUser", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUserAuthorization", import("../context/BackendRuntimeContext").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "mobile", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthApplication", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthProvider", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUser", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUserAuthorization", import("../context/BackendRuntimeContext").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "mobile", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import { Trigger } from 'oak-domain/lib/types/Trigger';
|
||||
import { EntityDict } from '../oak-app-domain/EntityDict';
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
import { MessageNotificationConverter } from '../types/Message';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { Router } from '../entities/Message';
|
||||
export declare function registerMessageNotificationConverters<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(converters: MessageNotificationConverter<ED, Cxt>[]): void;
|
||||
export declare function tryMakeSmsNotification(message: {
|
||||
userId?: string;
|
||||
type?: string;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,7 @@
|
|||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
import { assert } from 'oak-domain/lib/utils/assert';
|
||||
import { uniqBy } from 'oak-domain/lib/utils/lodash';
|
||||
const ConverterDict = {};
|
||||
export function registerMessageNotificationConverters(converters) {
|
||||
converters.forEach(ele => {
|
||||
assert(!ConverterDict[ele.type]);
|
||||
ConverterDict[ele.type] = ele;
|
||||
});
|
||||
}
|
||||
import { ConverterDict, getMessageHandler } from '../utils/message';
|
||||
const InitialChannelByWeightMatrix = {
|
||||
high: ['wechatMp', 'wechatPublic', 'sms', 'email'],
|
||||
medium: ['wechatMp', 'wechatPublic', 'email'],
|
||||
|
|
@ -137,115 +131,15 @@ async function createNotification(message, context) {
|
|||
const { application$system: applications, config } = system;
|
||||
const notificationDatas = [];
|
||||
await Promise.all(channels2.map(async (channel) => {
|
||||
switch (channel) {
|
||||
case 'wechatMp': {
|
||||
const apps = applications.filter(ele => ele.type === 'wechatMp');
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map(ele => ele.id),
|
||||
},
|
||||
userId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatMp;
|
||||
const dispersedData = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (dispersedData) {
|
||||
notificationDatas.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data: dispersedData,
|
||||
channel,
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'wechatPublic': {
|
||||
const apps = applications.filter(ele => ele.type === 'wechatPublic');
|
||||
const [user] = await context.select('user', {
|
||||
data: {
|
||||
id: 1,
|
||||
refId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: userId
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const userIds = user.refId ? [userId, user.refId] : [userId];
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map((ele) => ele.id),
|
||||
},
|
||||
userId: {
|
||||
$in: userIds
|
||||
},
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatPublic;
|
||||
const disperseResult = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (disperseResult) {
|
||||
const { data, wechatMpAppId } = disperseResult;
|
||||
notificationDatas.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data,
|
||||
channel,
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
wechatMpAppId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'email': {
|
||||
const emailNotification = await tryMakeEmailNotification(message, context);
|
||||
if (emailNotification) {
|
||||
notificationDatas.push(emailNotification);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(channel === 'sms'); // 目前只支持三种
|
||||
const smsNotification = await tryMakeSmsNotification(message, context);
|
||||
if (smsNotification) {
|
||||
notificationDatas.push(smsNotification);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
const handler = getMessageHandler(channel);
|
||||
const channelNotifications = await handler({
|
||||
message,
|
||||
applications: applications,
|
||||
system,
|
||||
messageTypeTemplates,
|
||||
context,
|
||||
});
|
||||
notificationDatas.push(...channelNotifications);
|
||||
}));
|
||||
const messageSystemData = {
|
||||
id: await generateNewIdAsync(),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ async function sendNotification(notification, context) {
|
|||
await instance.sendSubscribedMessage({
|
||||
templateId: templateId,
|
||||
data: data,
|
||||
openId: data1.openId,
|
||||
openId: data1.openId, // 在notification创建时就赋值了
|
||||
page,
|
||||
state: StateDict[process.env.NODE_ENV],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
|
|||
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
|
||||
entity: any;
|
||||
entityId: string;
|
||||
}, userIds?: string[]): Promise<0 | 1>;
|
||||
}, userIds?: string[]): Promise<1 | 0>;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ import { EntityDict } from '../oak-app-domain';
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EmailOptions } from './Email';
|
||||
type WechatPublicTemplateMsgKeyword = 'keyword1' | 'keyword2' | 'keyword3' | 'keyword4' | 'keyword5' | 'keyword6' | 'keyword7';
|
||||
export type Channel = 'wechatPublic' | 'jPush' | 'jim' | 'wechatMp' | 'sms' | 'email';
|
||||
export type Channel = 'wechatPublic' | 'jPush' | 'jim' | 'wechatMp' | 'sms' | 'email' | string;
|
||||
export type Weight = 'high' | 'medium' | 'low';
|
||||
export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> {
|
||||
type: string;
|
||||
type CommonMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
|
||||
toWechatMp?: (message: ED['message']['OpSchema'], applications: EntityDict['application']['Schema'][], application: EntityDict['application']['Schema'], context: Cxt) => Promise<{
|
||||
[K: string]: {
|
||||
value: string;
|
||||
|
|
@ -35,5 +34,13 @@ export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends
|
|||
paramsArray?: Array<string>;
|
||||
} | undefined>;
|
||||
toEmail?: (message: ED['message']['OpSchema'], context: Cxt) => Promise<EmailOptions | undefined>;
|
||||
};
|
||||
type CustomMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
|
||||
[type: string]: {
|
||||
[key: string]: (message: ED['message']['OpSchema'], context: Cxt) => Promise<Object | undefined>;
|
||||
};
|
||||
};
|
||||
export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> {
|
||||
[type: string]: CommonMessageConverter<ED, Cxt> & CustomMessageConverter<ED, Cxt>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File | string): Promise<string>;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export function calculateFileMd5(file) {
|
||||
return new Promise((revlove) => {
|
||||
revlove('dummy-md5-hash-for-index');
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(filePath: string): Promise<string>;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
export async function calculateFileMd5(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fs = wx.getFileSystemManager();
|
||||
fs.getFileInfo({
|
||||
filePath: filePath,
|
||||
digestAlgorithm: 'md5',
|
||||
success(res) {
|
||||
resolve(res.digest);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File): Promise<string>;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import SparkMd5 from 'spark-md5';
|
||||
export function calculateFileMd5(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 2097152;
|
||||
const chunks = Math.ceil(file.size / chunkSize);
|
||||
let currentChunk = 0;
|
||||
const spark = new SparkMd5.ArrayBuffer();
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function (e) {
|
||||
spark.append(e.target?.result);
|
||||
currentChunk++;
|
||||
if (currentChunk < chunks) {
|
||||
loadNext();
|
||||
}
|
||||
else {
|
||||
resolve(spark.end());
|
||||
}
|
||||
};
|
||||
fileReader.onerror = function () {
|
||||
reject(new Error('Failed to read file'));
|
||||
};
|
||||
function loadNext() {
|
||||
const start = currentChunk * chunkSize;
|
||||
const end = Math.min(start + chunkSize, file.size);
|
||||
fileReader.readAsArrayBuffer(file.slice(start, end));
|
||||
}
|
||||
loadNext();
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File): Promise<string>;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import SparkMd5 from 'spark-md5';
|
||||
export function calculateFileMd5(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 2097152;
|
||||
const chunks = Math.ceil(file.size / chunkSize);
|
||||
let currentChunk = 0;
|
||||
const spark = new SparkMd5.ArrayBuffer();
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function (e) {
|
||||
spark.append(e.target?.result);
|
||||
currentChunk++;
|
||||
if (currentChunk < chunks) {
|
||||
loadNext();
|
||||
}
|
||||
else {
|
||||
resolve(spark.end());
|
||||
}
|
||||
};
|
||||
fileReader.onerror = function () {
|
||||
reject(new Error('Failed to read file'));
|
||||
};
|
||||
function loadNext() {
|
||||
const start = currentChunk * chunkSize;
|
||||
const end = Math.min(start + chunkSize, file.size);
|
||||
fileReader.readAsArrayBuffer(file.slice(start, end));
|
||||
}
|
||||
loadNext();
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const emailHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { tryMakeEmailNotification } from '../../triggers/message';
|
||||
export const emailHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const notificationDatas = [];
|
||||
const emailNotification = await tryMakeEmailNotification(message, context);
|
||||
if (emailNotification) {
|
||||
notificationDatas.push(emailNotification);
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { EntityDict } from "../../oak-app-domain";
|
||||
import { BRC } from "../../types/RuntimeCxt";
|
||||
import { CreateOperationData as CreateMessageData } from '../../oak-app-domain/Message/Schema';
|
||||
import { Channel, MessageNotificationConverter } from "../../types/Message";
|
||||
import BackendRuntimeContext from "../../context/BackendRuntimeContext";
|
||||
export type MessageHandler = (options: {
|
||||
message: CreateMessageData;
|
||||
applications: Partial<EntityDict['application']['Schema']>[];
|
||||
system: EntityDict['system']['Schema'];
|
||||
messageTypeTemplates: Partial<EntityDict['messageTypeTemplate']['Schema']>[];
|
||||
context: BRC<EntityDict>;
|
||||
}) => Promise<Omit<EntityDict['notification']['CreateOperationData'], 'messageSystemId'>[]>;
|
||||
export declare const ConverterDict: Record<string, MessageNotificationConverter<EntityDict, BackendRuntimeContext<any>>[string]>;
|
||||
export declare function registerMessageNotificationConverters<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(converter: MessageNotificationConverter<ED, Cxt>): void;
|
||||
export declare function registerMessageHandler(channel: Channel, handler: MessageHandler): void;
|
||||
export declare function getMessageHandler(channel: Channel): MessageHandler;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { assert } from "oak-domain/lib/utils/assert";
|
||||
export const ConverterDict = {};
|
||||
export function registerMessageNotificationConverters(converter) {
|
||||
Object.keys(converter).forEach(key => {
|
||||
ConverterDict[key] = converter[key];
|
||||
});
|
||||
}
|
||||
const messageHandlers = {};
|
||||
export function registerMessageHandler(channel, handler) {
|
||||
messageHandlers[channel] = handler;
|
||||
}
|
||||
export function getMessageHandler(channel) {
|
||||
const handler = messageHandlers[channel];
|
||||
assert(handler, `消息渠道 ${channel} 的处理器未注册`);
|
||||
return handler;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const smsHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { tryMakeSmsNotification } from '../../triggers/message';
|
||||
export const smsHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const notificationDatas = [];
|
||||
const smsNotification = await tryMakeSmsNotification(message, context);
|
||||
if (smsNotification) {
|
||||
notificationDatas.push(smsNotification);
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const wechatMpHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
import { ConverterDict } from './index';
|
||||
export const wechatMpHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const { userId, type } = message;
|
||||
const notificationDatas = [];
|
||||
const apps = applications.filter(ele => ele.type === 'wechatMp');
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map(ele => ele.id),
|
||||
},
|
||||
userId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatMp;
|
||||
const dispersedData = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (dispersedData) {
|
||||
notificationDatas.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data: dispersedData,
|
||||
channel: 'wechatMp',
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const wechatPublicHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
import { ConverterDict } from './index';
|
||||
export const wechatPublicHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const { userId, type } = message;
|
||||
const notificationDatas = [];
|
||||
const apps = applications.filter(ele => ele.type === 'wechatPublic');
|
||||
const [user] = await context.select('user', {
|
||||
data: {
|
||||
id: 1,
|
||||
refId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: userId
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const userIds = user.refId ? [userId, user.refId] : [userId];
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map((ele) => ele.id),
|
||||
},
|
||||
userId: {
|
||||
$in: userIds
|
||||
},
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatPublic;
|
||||
const disperseResult = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (disperseResult) {
|
||||
const { data, wechatMpAppId } = disperseResult;
|
||||
notificationDatas.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data,
|
||||
channel: 'wechatPublic',
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
wechatMpAppId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.removeApplicationPassportsByPIds = exports.getApplicationPassports = void 0;
|
||||
exports.getApplicationPassports = getApplicationPassports;
|
||||
exports.removeApplicationPassportsByPIds = removeApplicationPassportsByPIds;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
async function getApplicationPassports(params, context) {
|
||||
const { applicationId } = params;
|
||||
|
|
@ -23,7 +24,6 @@ async function getApplicationPassports(params, context) {
|
|||
closeRoot();
|
||||
return applicationPassports;
|
||||
}
|
||||
exports.getApplicationPassports = getApplicationPassports;
|
||||
async function removeApplicationPassportsByPIds(params, context) {
|
||||
const { passportIds } = params;
|
||||
const applicationPassports = await context.select('applicationPassport', {
|
||||
|
|
@ -51,4 +51,3 @@ async function removeApplicationPassportsByPIds(params, context) {
|
|||
}, {});
|
||||
}
|
||||
}
|
||||
exports.removeApplicationPassportsByPIds = removeApplicationPassportsByPIds;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateStyle = exports.updateApplicationConfig = exports.updateConfig = void 0;
|
||||
exports.updateConfig = updateConfig;
|
||||
exports.updateApplicationConfig = updateApplicationConfig;
|
||||
exports.updateStyle = updateStyle;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
async function updateConfig(params, context) {
|
||||
const { entity, entityId, config } = params;
|
||||
|
|
@ -15,7 +17,6 @@ async function updateConfig(params, context) {
|
|||
}
|
||||
}, {});
|
||||
}
|
||||
exports.updateConfig = updateConfig;
|
||||
async function updateApplicationConfig(params, context) {
|
||||
const { entity, entityId, config } = params;
|
||||
await context.operate(entity, {
|
||||
|
|
@ -29,7 +30,6 @@ async function updateApplicationConfig(params, context) {
|
|||
},
|
||||
}, {});
|
||||
}
|
||||
exports.updateApplicationConfig = updateApplicationConfig;
|
||||
async function updateStyle(params, context) {
|
||||
const { entity, entityId, style } = params;
|
||||
await context.operate(entity, {
|
||||
|
|
@ -43,4 +43,3 @@ async function updateStyle(params, context) {
|
|||
},
|
||||
}, {});
|
||||
}
|
||||
exports.updateStyle = updateStyle;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uploadExtraFile = exports.getInfoByUrl = void 0;
|
||||
exports.getInfoByUrl = getInfoByUrl;
|
||||
exports.uploadExtraFile = uploadExtraFile;
|
||||
const tslib_1 = require("tslib");
|
||||
const WechatSDK_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/WechatSDK"));
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
|
|
@ -13,7 +14,6 @@ async function getInfoByUrl(params) {
|
|||
const { url } = params;
|
||||
return await WechatSDK_1.default.analyzePublicArticle(url);
|
||||
}
|
||||
exports.getInfoByUrl = getInfoByUrl;
|
||||
async function uploadExtraFile(params, // FormData表单提交
|
||||
context) {
|
||||
const { applicationId, file, extraFileId, } = params;
|
||||
|
|
@ -54,4 +54,3 @@ context) {
|
|||
success: true,
|
||||
};
|
||||
}
|
||||
exports.uploadExtraFile = uploadExtraFile;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.authorize = exports.createOAuthState = exports.getOAuthClientInfo = exports.loginByOauth = void 0;
|
||||
exports.loginByOauth = loginByOauth;
|
||||
exports.getOAuthClientInfo = getOAuthClientInfo;
|
||||
exports.createOAuthState = createOAuthState;
|
||||
exports.authorize = authorize;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const types_1 = require("oak-domain/lib/types");
|
||||
|
|
@ -184,7 +187,6 @@ async function loginByOauth(params, context) {
|
|||
return tokenValue;
|
||||
}
|
||||
}
|
||||
exports.loginByOauth = loginByOauth;
|
||||
async function getOAuthClientInfo(params, context) {
|
||||
const { client_id, currentUserId } = params;
|
||||
const closeRootMode = context.openRootMode();
|
||||
|
|
@ -247,7 +249,6 @@ async function getOAuthClientInfo(params, context) {
|
|||
alreadyAuth: !!hasAuth,
|
||||
};
|
||||
}
|
||||
exports.getOAuthClientInfo = getOAuthClientInfo;
|
||||
async function createOAuthState(params, context) {
|
||||
const { providerId, userId, type } = params;
|
||||
const closeRootMode = context.openRootMode();
|
||||
|
|
@ -269,7 +270,6 @@ async function createOAuthState(params, context) {
|
|||
closeRootMode();
|
||||
return state;
|
||||
}
|
||||
exports.createOAuthState = createOAuthState;
|
||||
async function authorize(params, context) {
|
||||
const { response_type, client_id, redirect_uri, scope, state, action, code_challenge, code_challenge_method } = params;
|
||||
if (response_type !== 'code') {
|
||||
|
|
@ -336,7 +336,7 @@ async function authorize(params, context) {
|
|||
applicationId: context.getApplicationId(),
|
||||
userId: context.getCurrentUserId(),
|
||||
scope: scope === undefined ? [] : [scope],
|
||||
expiresAt: Date.now() + 10 * 60 * 1000,
|
||||
expiresAt: Date.now() + 10 * 60 * 1000, // 10分钟后过期
|
||||
// PKCE 支持
|
||||
codeChallenge: code_challenge,
|
||||
codeChallengeMethod: code_challenge_method || 'plain',
|
||||
|
|
@ -366,7 +366,6 @@ async function authorize(params, context) {
|
|||
closeRootMode();
|
||||
throw new Error('unknown action');
|
||||
}
|
||||
exports.authorize = authorize;
|
||||
const fetchOAuthUserInfo = async (code, providerConfig) => {
|
||||
// 1. 使用 code 换取 access_token
|
||||
const tokenResponse = await fetch(providerConfig.tokenEndpoint, {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createSession = void 0;
|
||||
exports.createSession = createSession;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
async function createSession(params, context) {
|
||||
|
|
@ -106,7 +106,7 @@ async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'image',
|
||||
tag1: 'image',
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(),
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
@ -131,7 +131,7 @@ async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'video',
|
||||
tag1: 'video',
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(),
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
@ -153,7 +153,7 @@ async function createSession(params, context) {
|
|||
origin: 'wechat',
|
||||
type: 'audio',
|
||||
tag1: 'audio',
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(),
|
||||
objectId: await (0, uuid_1.generateNewIdAsync)(), // 这个域用来标识唯一性
|
||||
sort: 1000,
|
||||
uploadState: 'success',
|
||||
extra1: data.MediaId,
|
||||
|
|
@ -222,4 +222,3 @@ async function createSession(params, context) {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
exports.createSession = createSession;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.syncSmsTemplate = void 0;
|
||||
exports.syncSmsTemplate = syncSmsTemplate;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const index_1 = require("../utils/sms/index");
|
||||
async function syncSmsTemplate(params, context) {
|
||||
|
|
@ -83,4 +83,3 @@ async function syncSmsTemplate(params, context) {
|
|||
// );
|
||||
// }
|
||||
}
|
||||
exports.syncSmsTemplate = syncSmsTemplate;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.syncMessageTemplate = exports.getMessageType = exports.registerMessageType = void 0;
|
||||
exports.registerMessageType = registerMessageType;
|
||||
exports.getMessageType = getMessageType;
|
||||
exports.syncMessageTemplate = syncMessageTemplate;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
|
|
@ -11,11 +13,9 @@ function registerMessageType(messageType) {
|
|||
let messageTypes2 = messageTypes.concat(messageType);
|
||||
messageTypes = (0, lodash_1.uniq)(messageTypes2);
|
||||
}
|
||||
exports.registerMessageType = registerMessageType;
|
||||
async function getMessageType() {
|
||||
return messageTypes;
|
||||
}
|
||||
exports.getMessageType = getMessageType;
|
||||
function analyseContent(content) {
|
||||
let content2 = content;
|
||||
let result = {};
|
||||
|
|
@ -129,4 +129,3 @@ async function syncMessageTemplate(params, context) {
|
|||
}
|
||||
return template_list;
|
||||
}
|
||||
exports.syncMessageTemplate = syncMessageTemplate;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.syncToWechat = exports.syncToLocale = exports.tagging = exports.getSubscribedUserInfo = exports.getUsers = exports.getUserTags = exports.batchuntagging = exports.batchtagging = exports.getTagUsers = void 0;
|
||||
exports.getTagUsers = getTagUsers;
|
||||
exports.batchtagging = batchtagging;
|
||||
exports.batchuntagging = batchuntagging;
|
||||
exports.getUserTags = getUserTags;
|
||||
exports.getUsers = getUsers;
|
||||
exports.getSubscribedUserInfo = getSubscribedUserInfo;
|
||||
exports.tagging = tagging;
|
||||
exports.syncToLocale = syncToLocale;
|
||||
exports.syncToWechat = syncToWechat;
|
||||
const tslib_1 = require("tslib");
|
||||
const WechatSDK_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/WechatSDK"));
|
||||
const wechatPublicException_1 = require("../utils/wechatPublicException");
|
||||
|
|
@ -146,7 +154,6 @@ async function getTagUsers(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.getTagUsers = getTagUsers;
|
||||
async function batchtagging(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -160,7 +167,6 @@ async function batchtagging(params, context) {
|
|||
const result = await wechatInstance.batchtagging(params.openIdList, params.tagId);
|
||||
return result;
|
||||
}
|
||||
exports.batchtagging = batchtagging;
|
||||
async function batchuntagging(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -174,7 +180,6 @@ async function batchuntagging(params, context) {
|
|||
const result = await wechatInstance.batchuntagging(params.openIdList, params.tagId);
|
||||
return result;
|
||||
}
|
||||
exports.batchuntagging = batchuntagging;
|
||||
async function getUserTags(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -193,7 +198,6 @@ async function getUserTags(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.getUserTags = getUserTags;
|
||||
async function getUsers(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -212,7 +216,6 @@ async function getUsers(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.getUsers = getUsers;
|
||||
async function getSubscribedUserInfo(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -231,7 +234,6 @@ async function getSubscribedUserInfo(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.getSubscribedUserInfo = getSubscribedUserInfo;
|
||||
async function tagging(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -310,7 +312,6 @@ async function tagging(params, context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
exports.tagging = tagging;
|
||||
async function syncToLocale(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -390,7 +391,6 @@ async function syncToLocale(params, context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
exports.syncToLocale = syncToLocale;
|
||||
async function syncToWechat(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -454,4 +454,3 @@ async function syncToWechat(params, context) {
|
|||
}, {});
|
||||
}
|
||||
}
|
||||
exports.syncToWechat = syncToWechat;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createWechatLogin = void 0;
|
||||
exports.createWechatLogin = createWechatLogin;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
async function createWechatLogin(params, context) {
|
||||
const { type, interval } = params;
|
||||
|
|
@ -44,4 +44,3 @@ async function createWechatLogin(params, context) {
|
|||
}
|
||||
return id;
|
||||
}
|
||||
exports.createWechatLogin = createWechatLogin;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wechatMpJump = void 0;
|
||||
exports.wechatMpJump = wechatMpJump;
|
||||
const tslib_1 = require("tslib");
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
const Projection_1 = require("../types/Projection");
|
||||
|
|
@ -51,4 +51,3 @@ async function wechatMpJump(params, context) {
|
|||
const result = await wechatInstance.getURLScheme({ jump_wxa, expireType, expiresAt, expireInterval });
|
||||
return result;
|
||||
}
|
||||
exports.wechatMpJump = wechatMpJump;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.oneKeySync = exports.syncTag = exports.deleteTag = exports.editTag = exports.getTags = exports.createTag = void 0;
|
||||
exports.createTag = createTag;
|
||||
exports.getTags = getTags;
|
||||
exports.editTag = editTag;
|
||||
exports.deleteTag = deleteTag;
|
||||
exports.syncTag = syncTag;
|
||||
exports.oneKeySync = oneKeySync;
|
||||
const tslib_1 = require("tslib");
|
||||
const WechatSDK_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/WechatSDK"));
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
|
|
@ -67,7 +72,6 @@ async function createTag(params, context) {
|
|||
const result = await wechatInstance.createTag({ name: params.name });
|
||||
return result;
|
||||
}
|
||||
exports.createTag = createTag;
|
||||
async function getTags(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -81,7 +85,6 @@ async function getTags(params, context) {
|
|||
const result = await wechatInstance.getTags();
|
||||
return result;
|
||||
}
|
||||
exports.getTags = getTags;
|
||||
async function editTag(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -98,7 +101,6 @@ async function editTag(params, context) {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
exports.editTag = editTag;
|
||||
async function deleteTag(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -112,7 +114,6 @@ async function deleteTag(params, context) {
|
|||
const result = await wechatInstance.deleteTag({ id: params.wechatId });
|
||||
return result;
|
||||
}
|
||||
exports.deleteTag = deleteTag;
|
||||
async function syncTag(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -197,7 +198,6 @@ async function syncTag(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.syncTag = syncTag;
|
||||
async function oneKeySync(params, context) {
|
||||
const application = await getWechatPublicConfig(params.applicationId, context);
|
||||
(0, assert_1.assert)(application);
|
||||
|
|
@ -279,4 +279,3 @@ async function oneKeySync(params, context) {
|
|||
throw new types_1.OakPreConditionUnsetException(`${(0, wechatPublicException_1.handleException)(e)}`);
|
||||
}
|
||||
}
|
||||
exports.oneKeySync = oneKeySync;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMpUnlimitWxaCode = exports.createWechatQrCode = void 0;
|
||||
exports.createWechatQrCode = createWechatQrCode;
|
||||
exports.getMpUnlimitWxaCode = getMpUnlimitWxaCode;
|
||||
const tslib_1 = require("tslib");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
|
|
@ -166,7 +167,7 @@ async function createWechatQrCode(options, context) {
|
|||
permanent,
|
||||
url,
|
||||
expired: false,
|
||||
expiresAt: Date.now() + 2592000 * 1000,
|
||||
expiresAt: Date.now() + 2592000 * 1000, // wecharQrCode里的过期时间都放到最大,由上层关联对象来主动过期(by Xc, 20230131)
|
||||
props,
|
||||
};
|
||||
// 直接创建
|
||||
|
|
@ -218,7 +219,6 @@ async function createWechatQrCode(options, context) {
|
|||
data,
|
||||
}, {});
|
||||
}
|
||||
exports.createWechatQrCode = createWechatQrCode;
|
||||
async function getMpUnlimitWxaCode(wechatQrCodeId, context) {
|
||||
const [wechatQrCode] = await context.select('wechatQrCode', {
|
||||
data: {
|
||||
|
|
@ -257,4 +257,3 @@ async function getMpUnlimitWxaCode(wechatQrCodeId, context) {
|
|||
return str;
|
||||
}
|
||||
}
|
||||
exports.getMpUnlimitWxaCode = getMpUnlimitWxaCode;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unbindingWechat = void 0;
|
||||
exports.unbindingWechat = unbindingWechat;
|
||||
const types_1 = require("oak-domain/lib/types");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
|
|
@ -67,4 +67,3 @@ async function unbindingWechat(params, context) {
|
|||
fn();
|
||||
}
|
||||
}
|
||||
exports.unbindingWechat = unbindingWechat;
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ exports.entityDesc = {
|
|||
zh_CN: {
|
||||
name: '直播流',
|
||||
attr: {
|
||||
title: '名称',
|
||||
title: '名称', // 用户定义直播间名称,
|
||||
streamTitle: '直播流名称',
|
||||
liveonly: '活跃状态',
|
||||
hub: '直播空间名称',
|
||||
hub: '直播空间名称', // 所属直播空间名称
|
||||
entity: '所属实体',
|
||||
entityId: '所属实体id',
|
||||
rtmpPushUrl: '推流地址',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = useFeatures;
|
||||
const features_1 = require("oak-frontend-base/es/platforms/web/features");
|
||||
// react 独有
|
||||
function useFeatures() {
|
||||
return (0, features_1.useFeatures)();
|
||||
}
|
||||
exports.default = useFeatures;
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = useMyInfo;
|
||||
const tslib_1 = require("tslib");
|
||||
const react_1 = require("react");
|
||||
const useFeatures_1 = tslib_1.__importDefault(require("./useFeatures"));
|
||||
|
|
@ -54,4 +55,3 @@ function useMyInfo() {
|
|||
mobile,
|
||||
};
|
||||
}
|
||||
exports.default = useMyInfo;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ export {
|
|||
*/
|
||||
registerMessageType, } from './aspects/template';
|
||||
export { registerWeChatPublicEventCallback, } from './endpoints/wechat';
|
||||
export { registerMessageNotificationConverters, } from './triggers/message';
|
||||
export { registerMessageNotificationConverters, registerMessageHandler, } from './utils/message';
|
||||
export { registSms, } from './utils/sms';
|
||||
export { registerCosBackend, } from './utils/cos/index.backend';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* 如需要注入,请在routine中编写注册逻辑,使用此处提供的注册方法进行注册
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerCosBackend = exports.registSms = exports.registerMessageNotificationConverters = exports.registerWeChatPublicEventCallback = exports.registerMessageType = void 0;
|
||||
exports.registerCosBackend = exports.registSms = exports.registerMessageHandler = exports.registerMessageNotificationConverters = exports.registerWeChatPublicEventCallback = exports.registerMessageType = void 0;
|
||||
var template_1 = require("./aspects/template");
|
||||
/**
|
||||
* 注册消息类型
|
||||
|
|
@ -13,9 +13,10 @@ Object.defineProperty(exports, "registerMessageType", { enumerable: true, get: f
|
|||
var wechat_1 = require("./endpoints/wechat");
|
||||
// 注册微信事件回调处理器endpoint
|
||||
Object.defineProperty(exports, "registerWeChatPublicEventCallback", { enumerable: true, get: function () { return wechat_1.registerWeChatPublicEventCallback; } });
|
||||
var message_1 = require("./triggers/message");
|
||||
var message_1 = require("./utils/message");
|
||||
// 注册消息通知转换器trigger
|
||||
Object.defineProperty(exports, "registerMessageNotificationConverters", { enumerable: true, get: function () { return message_1.registerMessageNotificationConverters; } });
|
||||
Object.defineProperty(exports, "registerMessageHandler", { enumerable: true, get: function () { return message_1.registerMessageHandler; } });
|
||||
var sms_1 = require("./utils/sms");
|
||||
// 注册短信服务商实现
|
||||
Object.defineProperty(exports, "registSms", { enumerable: true, get: function () { return sms_1.registSms; } });
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthApplication", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthProvider", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUser", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUserAuthorization", import("../context/BackendRuntimeContext").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "mobile", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthApplication", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthProvider", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUser", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "oauthUserAuthorization", import("../context/BackendRuntimeContext").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "mobile", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import { Trigger } from 'oak-domain/lib/types/Trigger';
|
||||
import { EntityDict } from '../oak-app-domain/EntityDict';
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
import { MessageNotificationConverter } from '../types/Message';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { Router } from '../entities/Message';
|
||||
export declare function registerMessageNotificationConverters<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(converters: MessageNotificationConverter<ED, Cxt>[]): void;
|
||||
export declare function tryMakeSmsNotification(message: {
|
||||
userId?: string;
|
||||
type?: string;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,11 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tryMakeEmailNotification = exports.tryMakeSmsNotification = exports.registerMessageNotificationConverters = void 0;
|
||||
exports.tryMakeSmsNotification = tryMakeSmsNotification;
|
||||
exports.tryMakeEmailNotification = tryMakeEmailNotification;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
const ConverterDict = {};
|
||||
function registerMessageNotificationConverters(converters) {
|
||||
converters.forEach(ele => {
|
||||
(0, assert_1.assert)(!ConverterDict[ele.type]);
|
||||
ConverterDict[ele.type] = ele;
|
||||
});
|
||||
}
|
||||
exports.registerMessageNotificationConverters = registerMessageNotificationConverters;
|
||||
const message_1 = require("../utils/message");
|
||||
const InitialChannelByWeightMatrix = {
|
||||
high: ['wechatMp', 'wechatPublic', 'sms', 'email'],
|
||||
medium: ['wechatMp', 'wechatPublic', 'email'],
|
||||
|
|
@ -32,7 +26,7 @@ async function tryMakeSmsNotification(message, context) {
|
|||
count: 1,
|
||||
}, { dontCollect: true });
|
||||
if (mobile) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toSms;
|
||||
const converter = message_1.ConverterDict[type] && message_1.ConverterDict[type].toSms;
|
||||
if (converter) {
|
||||
const dispersedData = await converter(message, context);
|
||||
if (dispersedData) {
|
||||
|
|
@ -46,10 +40,9 @@ async function tryMakeSmsNotification(message, context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
exports.tryMakeSmsNotification = tryMakeSmsNotification;
|
||||
async function tryMakeEmailNotification(message, context) {
|
||||
const { userId, type, entity, entityId, router } = message;
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toEmail;
|
||||
const converter = message_1.ConverterDict[type] && message_1.ConverterDict[type].toEmail;
|
||||
if (converter) {
|
||||
const dispersedData = await converter(message, context);
|
||||
if (dispersedData) {
|
||||
|
|
@ -61,7 +54,6 @@ async function tryMakeEmailNotification(message, context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
exports.tryMakeEmailNotification = tryMakeEmailNotification;
|
||||
async function createNotification(message, context) {
|
||||
const { restriction, userId, weight, type, entity, entityId, platformId, channels } = message;
|
||||
(0, assert_1.assert)(userId);
|
||||
|
|
@ -143,115 +135,15 @@ async function createNotification(message, context) {
|
|||
const { application$system: applications, config } = system;
|
||||
const notificationDatas = [];
|
||||
await Promise.all(channels2.map(async (channel) => {
|
||||
switch (channel) {
|
||||
case 'wechatMp': {
|
||||
const apps = applications.filter(ele => ele.type === 'wechatMp');
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map(ele => ele.id),
|
||||
},
|
||||
userId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatMp;
|
||||
const dispersedData = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (dispersedData) {
|
||||
notificationDatas.push({
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
data: dispersedData,
|
||||
channel,
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'wechatPublic': {
|
||||
const apps = applications.filter(ele => ele.type === 'wechatPublic');
|
||||
const [user] = await context.select('user', {
|
||||
data: {
|
||||
id: 1,
|
||||
refId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: userId
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const userIds = user.refId ? [userId, user.refId] : [userId];
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map((ele) => ele.id),
|
||||
},
|
||||
userId: {
|
||||
$in: userIds
|
||||
},
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = ConverterDict[type] && ConverterDict[type].toWechatPublic;
|
||||
const disperseResult = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (disperseResult) {
|
||||
const { data, wechatMpAppId } = disperseResult;
|
||||
notificationDatas.push({
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
data,
|
||||
channel,
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
wechatMpAppId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'email': {
|
||||
const emailNotification = await tryMakeEmailNotification(message, context);
|
||||
if (emailNotification) {
|
||||
notificationDatas.push(emailNotification);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
(0, assert_1.assert)(channel === 'sms'); // 目前只支持三种
|
||||
const smsNotification = await tryMakeSmsNotification(message, context);
|
||||
if (smsNotification) {
|
||||
notificationDatas.push(smsNotification);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
const handler = (0, message_1.getMessageHandler)(channel);
|
||||
const channelNotifications = await handler({
|
||||
message,
|
||||
applications: applications,
|
||||
system,
|
||||
messageTypeTemplates,
|
||||
context,
|
||||
});
|
||||
notificationDatas.push(...channelNotifications);
|
||||
}));
|
||||
const messageSystemData = {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ async function sendNotification(notification, context) {
|
|||
await instance.sendSubscribedMessage({
|
||||
templateId: templateId,
|
||||
data: data,
|
||||
openId: data1.openId,
|
||||
openId: data1.openId, // 在notification创建时就赋值了
|
||||
page,
|
||||
state: StateDict[process.env.NODE_ENV],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
|
|||
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
|
||||
entity: any;
|
||||
entityId: string;
|
||||
}, userIds?: string[]): Promise<0 | 1>;
|
||||
}, userIds?: string[]): Promise<1 | 0>;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.completeToDo = exports.createToDo = void 0;
|
||||
exports.createToDo = createToDo;
|
||||
exports.completeToDo = completeToDo;
|
||||
const tslib_1 = require("tslib");
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
const RelationAuth_1 = require("oak-domain/lib/store/RelationAuth");
|
||||
|
|
@ -73,7 +74,6 @@ async function createToDo(entity, filter, action, context, data, userIds) {
|
|||
}, { dontCollect: true });
|
||||
return 1;
|
||||
}
|
||||
exports.createToDo = createToDo;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
@ -120,4 +120,3 @@ async function completeToDo(entity, filter, action, context) {
|
|||
}
|
||||
return completed;
|
||||
}
|
||||
exports.completeToDo = completeToDo;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeException = exports.OakIncompleteConfig = exports.OakCantChangeVerifiedUser = exports.OakHasToVerifyPassword = exports.OakPasswordUnset = exports.OakUploadException = exports.OakApplicationLoadingException = exports.OakUserInfoLoadingException = exports.OakMpHaveToSubscribeMessage = exports.OakTokenExpiredException = exports.OakUserDisabledException = exports.OakUserInfoUncompletedException = exports.OakAuthenticationException = exports.OakMobileUnsetException = exports.OakChangeLoginWayException = exports.OakDistinguishUserException = void 0;
|
||||
exports.OakIncompleteConfig = exports.OakCantChangeVerifiedUser = exports.OakHasToVerifyPassword = exports.OakPasswordUnset = exports.OakUploadException = exports.OakApplicationLoadingException = exports.OakUserInfoLoadingException = exports.OakMpHaveToSubscribeMessage = exports.OakTokenExpiredException = exports.OakUserDisabledException = exports.OakUserInfoUncompletedException = exports.OakAuthenticationException = exports.OakMobileUnsetException = exports.OakChangeLoginWayException = exports.OakDistinguishUserException = void 0;
|
||||
exports.makeException = makeException;
|
||||
const types_1 = require("oak-domain/lib/types");
|
||||
class OakDistinguishUserException extends types_1.OakUserException {
|
||||
userId;
|
||||
|
|
@ -211,4 +212,3 @@ function makeException(data) {
|
|||
return e;
|
||||
}
|
||||
}
|
||||
exports.makeException = makeException;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ import { EntityDict } from '../oak-app-domain';
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EmailOptions } from './Email';
|
||||
type WechatPublicTemplateMsgKeyword = 'keyword1' | 'keyword2' | 'keyword3' | 'keyword4' | 'keyword5' | 'keyword6' | 'keyword7';
|
||||
export type Channel = 'wechatPublic' | 'jPush' | 'jim' | 'wechatMp' | 'sms' | 'email';
|
||||
export type Channel = 'wechatPublic' | 'jPush' | 'jim' | 'wechatMp' | 'sms' | 'email' | string;
|
||||
export type Weight = 'high' | 'medium' | 'low';
|
||||
export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> {
|
||||
type: string;
|
||||
type CommonMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
|
||||
toWechatMp?: (message: ED['message']['OpSchema'], applications: EntityDict['application']['Schema'][], application: EntityDict['application']['Schema'], context: Cxt) => Promise<{
|
||||
[K: string]: {
|
||||
value: string;
|
||||
|
|
@ -35,5 +34,13 @@ export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends
|
|||
paramsArray?: Array<string>;
|
||||
} | undefined>;
|
||||
toEmail?: (message: ED['message']['OpSchema'], context: Cxt) => Promise<EmailOptions | undefined>;
|
||||
};
|
||||
type CustomMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
|
||||
[type: string]: {
|
||||
[key: string]: (message: ED['message']['OpSchema'], context: Cxt) => Promise<Object | undefined>;
|
||||
};
|
||||
};
|
||||
export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> {
|
||||
[type: string]: CommonMessageConverter<ED, Cxt> & CustomMessageConverter<ED, Cxt>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.oakGetPackageJsonVersion = void 0;
|
||||
exports.oakGetPackageJsonVersion = oakGetPackageJsonVersion;
|
||||
// 命名为这个函数,将在编译时被注入项目根目录的package.json中的version
|
||||
function oakGetPackageJsonVersion() {
|
||||
return '1.0.0';
|
||||
}
|
||||
exports.oakGetPackageJsonVersion = oakGetPackageJsonVersion;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.composeLocationUrl = void 0;
|
||||
exports.composeLocationUrl = composeLocationUrl;
|
||||
function composeLocationUrl(location, url, props) {
|
||||
const { port, protocol, hostname } = location;
|
||||
let Url = `${protocol}//${hostname}`;
|
||||
|
|
@ -21,4 +21,3 @@ function composeLocationUrl(location, url, props) {
|
|||
}
|
||||
return Url;
|
||||
}
|
||||
exports.composeLocationUrl = composeLocationUrl;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeAreaDecendantFilter = exports.makeAreaAncestorFilter = void 0;
|
||||
exports.makeAreaAncestorFilter = makeAreaAncestorFilter;
|
||||
exports.makeAreaDecendantFilter = makeAreaDecendantFilter;
|
||||
const filter_1 = require("oak-domain/lib/store/filter");
|
||||
function makeAreaAncestorFilter(filter, level = 1, includeAll, includeSelf) {
|
||||
return (0, filter_1.makeTreeAncestorFilter)('area', 'parentId', filter, level, includeAll, includeSelf);
|
||||
}
|
||||
exports.makeAreaAncestorFilter = makeAreaAncestorFilter;
|
||||
function makeAreaDecendantFilter(filter, level = 1, includeAll, includeSelf) {
|
||||
return (0, filter_1.makeTreeDescendantFilter)('area', 'parentId', filter, level, includeAll, includeSelf);
|
||||
}
|
||||
exports.makeAreaDecendantFilter = makeAreaDecendantFilter;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.composeServerUrl = exports.composeDomainUrl = void 0;
|
||||
exports.composeDomainUrl = composeDomainUrl;
|
||||
exports.composeServerUrl = composeServerUrl;
|
||||
function composeDomainUrl(domain, url, props) {
|
||||
const { port, protocol, apiPath, url: domainUrl } = domain;
|
||||
let Url = `${protocol}//${domainUrl}`;
|
||||
|
|
@ -21,7 +22,6 @@ function composeDomainUrl(domain, url, props) {
|
|||
}
|
||||
return Url;
|
||||
}
|
||||
exports.composeDomainUrl = composeDomainUrl;
|
||||
function composeServerUrl(domain, url, props) {
|
||||
const { port, protocol, apiPath, url: domainUrl } = domain;
|
||||
let Url = `${protocol}//${domainUrl}`;
|
||||
|
|
@ -45,4 +45,3 @@ function composeServerUrl(domain, url, props) {
|
|||
}
|
||||
return Url;
|
||||
}
|
||||
exports.composeServerUrl = composeServerUrl;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sendEmail = void 0;
|
||||
exports.sendEmail = sendEmail;
|
||||
async function sendEmail(options, context) {
|
||||
const { text, html } = options;
|
||||
console.log('邮件内容:', html || text);
|
||||
}
|
||||
exports.sendEmail = sendEmail;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sendEmail = exports.getOrigin = exports.getEmail = exports.registerEmail = void 0;
|
||||
exports.registerEmail = registerEmail;
|
||||
exports.getEmail = getEmail;
|
||||
exports.getOrigin = getOrigin;
|
||||
exports.sendEmail = sendEmail;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const node_mailer_1 = tslib_1.__importDefault(require("./node-mailer"));
|
||||
|
|
@ -15,16 +18,13 @@ function registerEmail(clazz) {
|
|||
const instance = new clazz();
|
||||
EmailDict[instance.name] = instance;
|
||||
}
|
||||
exports.registerEmail = registerEmail;
|
||||
function getEmail(origin) {
|
||||
(0, assert_1.assert)(EmailDict.hasOwnProperty(origin));
|
||||
return EmailDict[origin];
|
||||
}
|
||||
exports.getEmail = getEmail;
|
||||
function getOrigin() {
|
||||
return Object.keys(EmailDict);
|
||||
}
|
||||
exports.getOrigin = getOrigin;
|
||||
async function sendEmail(options, context) {
|
||||
try {
|
||||
const instance = getEmail('nodemailer');
|
||||
|
|
@ -38,4 +38,3 @@ async function sendEmail(options, context) {
|
|||
};
|
||||
}
|
||||
}
|
||||
exports.sendEmail = sendEmail;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.bytesToSize = exports.getFileURL = void 0;
|
||||
exports.getFileURL = getFileURL;
|
||||
exports.bytesToSize = bytesToSize;
|
||||
//获取file文件url
|
||||
function getFileURL(file) {
|
||||
let getUrl = '';
|
||||
|
|
@ -20,7 +21,6 @@ function getFileURL(file) {
|
|||
}
|
||||
return getUrl;
|
||||
}
|
||||
exports.getFileURL = getFileURL;
|
||||
function bytesToSize(size) {
|
||||
let data = '';
|
||||
if (size < 0.1 * 1024) {
|
||||
|
|
@ -50,4 +50,3 @@ function bytesToSize(size) {
|
|||
return sizeStr.substring(0, index) + sizeStr.substring(index + 3, 2);
|
||||
return sizeStr;
|
||||
}
|
||||
exports.bytesToSize = bytesToSize;
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File | string): Promise<string>;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateFileMd5 = calculateFileMd5;
|
||||
function calculateFileMd5(file) {
|
||||
return new Promise((revlove) => {
|
||||
revlove('dummy-md5-hash-for-index');
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(filePath: string): Promise<string>;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateFileMd5 = calculateFileMd5;
|
||||
async function calculateFileMd5(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fs = wx.getFileSystemManager();
|
||||
fs.getFileInfo({
|
||||
filePath: filePath,
|
||||
digestAlgorithm: 'md5',
|
||||
success(res) {
|
||||
resolve(res.digest);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File): Promise<string>;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateFileMd5 = calculateFileMd5;
|
||||
const tslib_1 = require("tslib");
|
||||
const spark_md5_1 = tslib_1.__importDefault(require("spark-md5"));
|
||||
function calculateFileMd5(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 2097152;
|
||||
const chunks = Math.ceil(file.size / chunkSize);
|
||||
let currentChunk = 0;
|
||||
const spark = new spark_md5_1.default.ArrayBuffer();
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function (e) {
|
||||
spark.append(e.target?.result);
|
||||
currentChunk++;
|
||||
if (currentChunk < chunks) {
|
||||
loadNext();
|
||||
}
|
||||
else {
|
||||
resolve(spark.end());
|
||||
}
|
||||
};
|
||||
fileReader.onerror = function () {
|
||||
reject(new Error('Failed to read file'));
|
||||
};
|
||||
function loadNext() {
|
||||
const start = currentChunk * chunkSize;
|
||||
const end = Math.min(start + chunkSize, file.size);
|
||||
fileReader.readAsArrayBuffer(file.slice(start, end));
|
||||
}
|
||||
loadNext();
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export declare function calculateFileMd5(file: File): Promise<string>;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateFileMd5 = calculateFileMd5;
|
||||
const tslib_1 = require("tslib");
|
||||
const spark_md5_1 = tslib_1.__importDefault(require("spark-md5"));
|
||||
function calculateFileMd5(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 2097152;
|
||||
const chunks = Math.ceil(file.size / chunkSize);
|
||||
let currentChunk = 0;
|
||||
const spark = new spark_md5_1.default.ArrayBuffer();
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function (e) {
|
||||
spark.append(e.target?.result);
|
||||
currentChunk++;
|
||||
if (currentChunk < chunks) {
|
||||
loadNext();
|
||||
}
|
||||
else {
|
||||
resolve(spark.end());
|
||||
}
|
||||
};
|
||||
fileReader.onerror = function () {
|
||||
reject(new Error('Failed to read file'));
|
||||
};
|
||||
function loadNext() {
|
||||
const start = currentChunk * chunkSize;
|
||||
const end = Math.min(start + chunkSize, file.size);
|
||||
fileReader.readAsArrayBuffer(file.slice(start, end));
|
||||
}
|
||||
loadNext();
|
||||
});
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPlayBackUrl = exports.getStreamObj = exports.getLivestream = void 0;
|
||||
exports.getLivestream = getLivestream;
|
||||
exports.getStreamObj = getStreamObj;
|
||||
exports.getPlayBackUrl = getPlayBackUrl;
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const getContextConfig_1 = require("./getContextConfig");
|
||||
/**
|
||||
|
|
@ -27,7 +29,6 @@ async function getLivestream(params, context) {
|
|||
expireAt,
|
||||
};
|
||||
}
|
||||
exports.getLivestream = getLivestream;
|
||||
// 获取推拉流地址
|
||||
/**
|
||||
* 直播流已存在的情况下,获取推拉流地址
|
||||
|
|
@ -52,7 +53,6 @@ async function getStreamObj(params, context) {
|
|||
expireAt,
|
||||
};
|
||||
}
|
||||
exports.getStreamObj = getStreamObj;
|
||||
// 生成直播回放
|
||||
async function getPlayBackUrl(params, context) {
|
||||
const { streamTitle, start, end, origin } = params;
|
||||
|
|
@ -61,4 +61,3 @@ async function getPlayBackUrl(params, context) {
|
|||
const { hub, playBackDomain, liveHost } = config;
|
||||
return instance.getPlayBackUrl(hub, playBackDomain, streamTitle, start, end, 'POST', liveHost);
|
||||
}
|
||||
exports.getPlayBackUrl = getPlayBackUrl;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const emailHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.emailHandler = void 0;
|
||||
const message_1 = require("../../triggers/message");
|
||||
const emailHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const notificationDatas = [];
|
||||
const emailNotification = await (0, message_1.tryMakeEmailNotification)(message, context);
|
||||
if (emailNotification) {
|
||||
notificationDatas.push(emailNotification);
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
exports.emailHandler = emailHandler;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { EntityDict } from "../../oak-app-domain";
|
||||
import { BRC } from "../../types/RuntimeCxt";
|
||||
import { CreateOperationData as CreateMessageData } from '../../oak-app-domain/Message/Schema';
|
||||
import { Channel, MessageNotificationConverter } from "../../types/Message";
|
||||
import BackendRuntimeContext from "../../context/BackendRuntimeContext";
|
||||
export type MessageHandler = (options: {
|
||||
message: CreateMessageData;
|
||||
applications: Partial<EntityDict['application']['Schema']>[];
|
||||
system: EntityDict['system']['Schema'];
|
||||
messageTypeTemplates: Partial<EntityDict['messageTypeTemplate']['Schema']>[];
|
||||
context: BRC<EntityDict>;
|
||||
}) => Promise<Omit<EntityDict['notification']['CreateOperationData'], 'messageSystemId'>[]>;
|
||||
export declare const ConverterDict: Record<string, MessageNotificationConverter<EntityDict, BackendRuntimeContext<any>>[string]>;
|
||||
export declare function registerMessageNotificationConverters<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(converter: MessageNotificationConverter<ED, Cxt>): void;
|
||||
export declare function registerMessageHandler(channel: Channel, handler: MessageHandler): void;
|
||||
export declare function getMessageHandler(channel: Channel): MessageHandler;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConverterDict = void 0;
|
||||
exports.registerMessageNotificationConverters = registerMessageNotificationConverters;
|
||||
exports.registerMessageHandler = registerMessageHandler;
|
||||
exports.getMessageHandler = getMessageHandler;
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
exports.ConverterDict = {};
|
||||
function registerMessageNotificationConverters(converter) {
|
||||
Object.keys(converter).forEach(key => {
|
||||
exports.ConverterDict[key] = converter[key];
|
||||
});
|
||||
}
|
||||
const messageHandlers = {};
|
||||
function registerMessageHandler(channel, handler) {
|
||||
messageHandlers[channel] = handler;
|
||||
}
|
||||
function getMessageHandler(channel) {
|
||||
const handler = messageHandlers[channel];
|
||||
(0, assert_1.assert)(handler, `消息渠道 ${channel} 的处理器未注册`);
|
||||
return handler;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const smsHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.smsHandler = void 0;
|
||||
const message_1 = require("../../triggers/message");
|
||||
const smsHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const notificationDatas = [];
|
||||
const smsNotification = await (0, message_1.tryMakeSmsNotification)(message, context);
|
||||
if (smsNotification) {
|
||||
notificationDatas.push(smsNotification);
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
exports.smsHandler = smsHandler;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { MessageHandler } from './index';
|
||||
export declare const wechatMpHandler: MessageHandler;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wechatMpHandler = void 0;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const index_1 = require("./index");
|
||||
const wechatMpHandler = async ({ message, applications, system, messageTypeTemplates, context }) => {
|
||||
const { userId, type } = message;
|
||||
const notificationDatas = [];
|
||||
const apps = applications.filter(ele => ele.type === 'wechatMp');
|
||||
const wechatUsers = await context.select('wechatUser', {
|
||||
data: {
|
||||
id: 1,
|
||||
applicationId: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId: {
|
||||
$in: apps.map(ele => ele.id),
|
||||
},
|
||||
userId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
for (const app of apps) {
|
||||
// 如果是wechatMp或者wechat,还要保证用户已经有openId
|
||||
const wechatUser = wechatUsers.find(ele => ele.applicationId === app.id);
|
||||
const messageTypeTemplate = messageTypeTemplates.find(ele => ele.template.applicationId === app.id && ele.type === type);
|
||||
if (messageTypeTemplate && wechatUser) {
|
||||
const converter = index_1.ConverterDict[type] && index_1.ConverterDict[type].toWechatMp;
|
||||
const dispersedData = converter &&
|
||||
(await converter(message, apps, app, context));
|
||||
if (dispersedData) {
|
||||
notificationDatas.push({
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
data: dispersedData,
|
||||
channel: 'wechatMp',
|
||||
applicationId: app.id,
|
||||
templateId: messageTypeTemplate.template.wechatId,
|
||||
data1: {
|
||||
openId: wechatUser.openId,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return notificationDatas;
|
||||
};
|
||||
exports.wechatMpHandler = wechatMpHandler;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue