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