Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev
This commit is contained in:
commit
9b04eeb741
|
|
@ -86,7 +86,6 @@ export async function createSession(params, context) {
|
|||
aaoe: false,
|
||||
extra: data,
|
||||
userId,
|
||||
openId: FromUserName,
|
||||
};
|
||||
if (MsgType === 'text') {
|
||||
Object.assign(sessionMessage, {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export default OakComponent({
|
|||
id: 1,
|
||||
text: 1,
|
||||
type: 1,
|
||||
openId: 1,
|
||||
userId: 1,
|
||||
wechatUserId: 1,
|
||||
applicationId: 1,
|
||||
|
|
@ -149,7 +148,6 @@ export default OakComponent({
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -264,7 +262,7 @@ export default OakComponent({
|
|||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
let origin = 'qiniu';
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.openId) {
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
origin = 'wechat';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -460,63 +460,67 @@ async function setSubscribedEventKey(openId, eventKey, context) {
|
|||
}
|
||||
}
|
||||
async function onWeChatPublicEvent(data, context) {
|
||||
const { ToUserName, FromUserName, CreateTime, MsgType, Event, EventKey, } = data;
|
||||
const { ToUserName, FromUserName, CreateTime, MsgType, Event, EventKey } = data;
|
||||
const appId = context.getApplicationId();
|
||||
let evt;
|
||||
// 如果有应用注入的事件回调则处理之,不依赖其返回
|
||||
if (CALLBACK[appId]) {
|
||||
CALLBACK[appId](data, context);
|
||||
}
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
// 接收事件推送
|
||||
if (MsgType === 'event') {
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const { MsgID: msgId, Status: status, FromUserName: openId, } = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const { MsgID: msgId, Status: status, FromUserName: openId, } = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
assert(MsgType);
|
||||
// 接收普通消息
|
||||
const content = '<xml>' +
|
||||
`<ToUserName>${FromUserName}</ToUserName>` +
|
||||
`<FromUserName>${ToUserName}</FromUserName>` +
|
||||
|
|
@ -542,10 +546,24 @@ async function onWeChatPublicEvent(data, context) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
createSession({ data, type: 'wechatPublic', entity: 'application', entityId: appId }, context);
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
try {
|
||||
await createSession({
|
||||
data,
|
||||
type: 'wechatPublic',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
}
|
||||
catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content,
|
||||
contentType: 'application/xml',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content,
|
||||
contentType: 'application/xml',
|
||||
|
|
@ -553,14 +571,22 @@ async function onWeChatPublicEvent(data, context) {
|
|||
}
|
||||
async function onWeChatMpEvent(data, context) {
|
||||
const appId = context.getApplicationId();
|
||||
createSession({
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
try {
|
||||
await createSession({
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
}
|
||||
catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content: 'success'
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
const endpoints = {
|
||||
|
|
@ -571,7 +597,7 @@ const endpoints = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -589,7 +615,7 @@ const endpoints = {
|
|||
fn: async (context, params, body, req, headers) => {
|
||||
const { searchParams } = new URL.URL(`http://${req.headers.host}${req.url}`);
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr');
|
||||
return echostr;
|
||||
|
|
@ -627,7 +653,7 @@ const endpoints = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -657,7 +683,7 @@ const endpoints = {
|
|||
fn: async (context, params, body, req, headers) => {
|
||||
const { searchParams } = new URL.URL(`http://${req.headers.host}${req.url}`);
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr');
|
||||
return echostr;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ export interface Schema extends EntityShape {
|
|||
link?: String<128>;
|
||||
aaoe?: Boolean;
|
||||
extra?: Object;
|
||||
openId?: String<32>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ const entityDesc = {
|
|||
link: '图文',
|
||||
aaoe: '作为实体的发起者',
|
||||
extra: '额外信息',
|
||||
openId: '微信用户openId',
|
||||
},
|
||||
v: {
|
||||
type: {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ExtraFile2 extends Feature {
|
|||
if (file instanceof File) {
|
||||
return getFileURL(file);
|
||||
}
|
||||
return file;
|
||||
assert(false, 'the incoming file is not supported');
|
||||
}
|
||||
const { origin } = extraFile;
|
||||
const cos = getCos(origin);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export type OpSchema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
export type Schema = EntityShape & {
|
||||
|
|
@ -36,7 +35,6 @@ export type Schema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
application: Application.Schema;
|
||||
session: Session.Schema;
|
||||
user?: User.Schema | null;
|
||||
|
|
@ -65,7 +63,6 @@ type AttrFilter = {
|
|||
link: Q_StringValue;
|
||||
aaoe: Q_BooleanValue;
|
||||
extra: Object;
|
||||
openId: Q_StringValue;
|
||||
extraFile$entity: ExtraFile.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
|
|
@ -90,7 +87,6 @@ export type Projection = {
|
|||
link?: number;
|
||||
aaoe?: number;
|
||||
extra?: number | Object;
|
||||
openId?: number;
|
||||
extraFile$entity?: ExtraFile.Selection & {
|
||||
$entity: "extraFile";
|
||||
};
|
||||
|
|
@ -147,8 +143,6 @@ export type SortAttr = {
|
|||
link: number;
|
||||
} | {
|
||||
aaoe: number;
|
||||
} | {
|
||||
openId: number;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
} | OneOf<ExprOp<OpAttr | string>>;
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@ export const desc = {
|
|||
},
|
||||
extra: {
|
||||
type: "object"
|
||||
},
|
||||
openId: {
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
}
|
||||
}
|
||||
},
|
||||
actionType: "crud",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "消息", "attr": { "application": "应用", "session": "会话", "user": "用户", "wechatUser": "微信用户", "createTime": "发送时间", "type": "消息类型", "text": "文本内容", "files": "文件", "link": "图文", "aaoe": "作为实体的发起者", "extra": "额外信息", "openId": "微信用户openId" }, "v": { "type": { "text": "文字", "image": "图片", "voice": "音频", "video": "视频", "link": "图文", "location": "位置", "event": "事件", "miniprogrampage": "小程序" } } }
|
||||
{ "name": "消息", "attr": { "application": "应用", "session": "会话", "user": "用户", "wechatUser": "微信用户", "createTime": "发送时间", "type": "消息类型", "text": "文本内容", "files": "文件", "link": "图文", "aaoe": "作为实体的发起者", "extra": "额外信息" }, "v": { "type": { "text": "文字", "image": "图片", "voice": "音频", "video": "视频", "link": "图文", "location": "位置", "event": "事件", "miniprogrampage": "小程序" } } }
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ const triggers = [
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -111,7 +110,7 @@ const triggers = [
|
|||
count: 1,
|
||||
indexFrom: 0,
|
||||
}, {});
|
||||
if (sessionMessage && sessionMessage.openId) {
|
||||
if (sessionMessage && sessionMessage.wechatUserId) {
|
||||
const [session] = await context.select('session', {
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
@ -146,11 +145,12 @@ const triggers = [
|
|||
const { appId, appSecret } = config;
|
||||
wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
|
||||
}
|
||||
const openId = sessionMessage.wechatUser.openId;
|
||||
//微信发送客服消息
|
||||
switch (msgType) {
|
||||
case 'text': {
|
||||
await wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId,
|
||||
openId,
|
||||
type: msgType,
|
||||
content: text,
|
||||
});
|
||||
|
|
@ -161,7 +161,7 @@ const triggers = [
|
|||
if (extraFile) {
|
||||
const mediaId = extraFile.extra1;
|
||||
wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId,
|
||||
openId,
|
||||
type: msgType,
|
||||
mediaId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ async function createSession(params, context) {
|
|||
aaoe: false,
|
||||
extra: data,
|
||||
userId,
|
||||
openId: FromUserName,
|
||||
};
|
||||
if (MsgType === 'text') {
|
||||
Object.assign(sessionMessage, {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ exports.default = OakComponent({
|
|||
id: 1,
|
||||
text: 1,
|
||||
type: 1,
|
||||
openId: 1,
|
||||
userId: 1,
|
||||
wechatUserId: 1,
|
||||
applicationId: 1,
|
||||
|
|
@ -151,7 +150,6 @@ exports.default = OakComponent({
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -266,7 +264,7 @@ exports.default = OakComponent({
|
|||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
let origin = 'qiniu';
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.openId) {
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
origin = 'wechat';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,63 +465,67 @@ async function setSubscribedEventKey(openId, eventKey, context) {
|
|||
}
|
||||
}
|
||||
async function onWeChatPublicEvent(data, context) {
|
||||
const { ToUserName, FromUserName, CreateTime, MsgType, Event, EventKey, } = data;
|
||||
const { ToUserName, FromUserName, CreateTime, MsgType, Event, EventKey } = data;
|
||||
const appId = context.getApplicationId();
|
||||
let evt;
|
||||
// 如果有应用注入的事件回调则处理之,不依赖其返回
|
||||
if (CALLBACK[appId]) {
|
||||
CALLBACK[appId](data, context);
|
||||
}
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
// 接收事件推送
|
||||
if (MsgType === 'event') {
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const { MsgID: msgId, Status: status, FromUserName: openId, } = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const { MsgID: msgId, Status: status, FromUserName: openId, } = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(data)}`;
|
||||
break;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
(0, assert_1.assert)(MsgType);
|
||||
// 接收普通消息
|
||||
const content = '<xml>' +
|
||||
`<ToUserName>${FromUserName}</ToUserName>` +
|
||||
`<FromUserName>${ToUserName}</FromUserName>` +
|
||||
|
|
@ -547,10 +551,24 @@ async function onWeChatPublicEvent(data, context) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
(0, session_1.createSession)({ data, type: 'wechatPublic', entity: 'application', entityId: appId }, context);
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
try {
|
||||
await (0, session_1.createSession)({
|
||||
data,
|
||||
type: 'wechatPublic',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
}
|
||||
catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content,
|
||||
contentType: 'application/xml',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content,
|
||||
contentType: 'application/xml',
|
||||
|
|
@ -558,14 +576,22 @@ async function onWeChatPublicEvent(data, context) {
|
|||
}
|
||||
async function onWeChatMpEvent(data, context) {
|
||||
const appId = context.getApplicationId();
|
||||
(0, session_1.createSession)({
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
try {
|
||||
await (0, session_1.createSession)({
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
}, context);
|
||||
}
|
||||
catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content: 'success'
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
const endpoints = {
|
||||
|
|
@ -576,7 +602,7 @@ const endpoints = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -594,7 +620,7 @@ const endpoints = {
|
|||
fn: async (context, params, body, req, headers) => {
|
||||
const { searchParams } = new url_1.default.URL(`http://${req.headers.host}${req.url}`);
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr');
|
||||
return echostr;
|
||||
|
|
@ -632,7 +658,7 @@ const endpoints = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -662,7 +688,7 @@ const endpoints = {
|
|||
fn: async (context, params, body, req, headers) => {
|
||||
const { searchParams } = new url_1.default.URL(`http://${req.headers.host}${req.url}`);
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr');
|
||||
return echostr;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ export interface Schema extends EntityShape {
|
|||
link?: String<128>;
|
||||
aaoe?: Boolean;
|
||||
extra?: Object;
|
||||
openId?: String<32>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ const entityDesc = {
|
|||
link: '图文',
|
||||
aaoe: '作为实体的发起者',
|
||||
extra: '额外信息',
|
||||
openId: '微信用户openId',
|
||||
},
|
||||
v: {
|
||||
type: {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class ExtraFile2 extends oak_frontend_base_1.Feature {
|
|||
if (file instanceof File) {
|
||||
return (0, extraFile_1.getFileURL)(file);
|
||||
}
|
||||
return file;
|
||||
(0, assert_1.assert)(false, 'the incoming file is not supported');
|
||||
}
|
||||
const { origin } = extraFile;
|
||||
const cos = (0, cos_1.getCos)(origin);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export type OpSchema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
export type Schema = EntityShape & {
|
||||
|
|
@ -36,7 +35,6 @@ export type Schema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
application: Application.Schema;
|
||||
session: Session.Schema;
|
||||
user?: User.Schema | null;
|
||||
|
|
@ -65,7 +63,6 @@ type AttrFilter = {
|
|||
link: Q_StringValue;
|
||||
aaoe: Q_BooleanValue;
|
||||
extra: Object;
|
||||
openId: Q_StringValue;
|
||||
extraFile$entity: ExtraFile.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
|
|
@ -90,7 +87,6 @@ export type Projection = {
|
|||
link?: number;
|
||||
aaoe?: number;
|
||||
extra?: number | Object;
|
||||
openId?: number;
|
||||
extraFile$entity?: ExtraFile.Selection & {
|
||||
$entity: "extraFile";
|
||||
};
|
||||
|
|
@ -147,8 +143,6 @@ export type SortAttr = {
|
|||
link: number;
|
||||
} | {
|
||||
aaoe: number;
|
||||
} | {
|
||||
openId: number;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
} | OneOf<ExprOp<OpAttr | string>>;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@ exports.desc = {
|
|||
},
|
||||
extra: {
|
||||
type: "object"
|
||||
},
|
||||
openId: {
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
}
|
||||
}
|
||||
},
|
||||
actionType: "crud",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "消息", "attr": { "application": "应用", "session": "会话", "user": "用户", "wechatUser": "微信用户", "createTime": "发送时间", "type": "消息类型", "text": "文本内容", "files": "文件", "link": "图文", "aaoe": "作为实体的发起者", "extra": "额外信息", "openId": "微信用户openId" }, "v": { "type": { "text": "文字", "image": "图片", "voice": "音频", "video": "视频", "link": "图文", "location": "位置", "event": "事件", "miniprogrampage": "小程序" } } }
|
||||
{ "name": "消息", "attr": { "application": "应用", "session": "会话", "user": "用户", "wechatUser": "微信用户", "createTime": "发送时间", "type": "消息类型", "text": "文本内容", "files": "文件", "link": "图文", "aaoe": "作为实体的发起者", "extra": "额外信息" }, "v": { "type": { "text": "文字", "image": "图片", "voice": "音频", "video": "视频", "link": "图文", "location": "位置", "event": "事件", "miniprogrampage": "小程序" } } }
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ const triggers = [
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -113,7 +112,7 @@ const triggers = [
|
|||
count: 1,
|
||||
indexFrom: 0,
|
||||
}, {});
|
||||
if (sessionMessage && sessionMessage.openId) {
|
||||
if (sessionMessage && sessionMessage.wechatUserId) {
|
||||
const [session] = await context.select('session', {
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
@ -148,11 +147,12 @@ const triggers = [
|
|||
const { appId, appSecret } = config;
|
||||
wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId, type, appSecret);
|
||||
}
|
||||
const openId = sessionMessage.wechatUser.openId;
|
||||
//微信发送客服消息
|
||||
switch (msgType) {
|
||||
case 'text': {
|
||||
await wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId,
|
||||
openId,
|
||||
type: msgType,
|
||||
content: text,
|
||||
});
|
||||
|
|
@ -163,7 +163,7 @@ const triggers = [
|
|||
if (extraFile) {
|
||||
const mediaId = extraFile.extra1;
|
||||
wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId,
|
||||
openId,
|
||||
type: msgType,
|
||||
mediaId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ export async function createSession<
|
|||
aaoe: false,
|
||||
extra: data,
|
||||
userId,
|
||||
openId: FromUserName,
|
||||
};
|
||||
if (MsgType === 'text') {
|
||||
Object.assign(sessionMessage, {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export default OakComponent({
|
|||
id: 1,
|
||||
text: 1,
|
||||
type: 1,
|
||||
openId: 1,
|
||||
userId: 1,
|
||||
wechatUserId: 1,
|
||||
applicationId: 1,
|
||||
|
|
@ -169,7 +168,6 @@ export default OakComponent({
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -305,7 +303,7 @@ export default OakComponent({
|
|||
|
||||
let origin: EntityDict['extraFile']['Schema']['origin'] = 'qiniu';
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.openId) {
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
origin = 'wechat';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -610,14 +610,8 @@ async function setSubscribedEventKey(
|
|||
}
|
||||
|
||||
async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC) {
|
||||
const {
|
||||
ToUserName,
|
||||
FromUserName,
|
||||
CreateTime,
|
||||
MsgType,
|
||||
Event,
|
||||
EventKey,
|
||||
} = data;
|
||||
const { ToUserName, FromUserName, CreateTime, MsgType, Event, EventKey } =
|
||||
data;
|
||||
|
||||
const appId = context.getApplicationId()!;
|
||||
let evt: string;
|
||||
|
|
@ -626,65 +620,72 @@ async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC) {
|
|||
if (CALLBACK[appId]) {
|
||||
CALLBACK[appId](data, context);
|
||||
}
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
|
||||
|
||||
// 接收事件推送
|
||||
if (MsgType === 'event') {
|
||||
if (Event) {
|
||||
const event = Event.toLowerCase();
|
||||
switch (event) {
|
||||
case 'subscribe':
|
||||
setUserSubscribed(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}关注公众号`;
|
||||
break;
|
||||
case 'scan':
|
||||
setUserSubscribed(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}再次扫描带${EventKey}键值的二维码`;
|
||||
break;
|
||||
case 'unsubscribe': {
|
||||
setUserUnsubscribed(FromUserName, context);
|
||||
evt = `用户${FromUserName}取关`;
|
||||
break;
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const {
|
||||
MsgID: msgId,
|
||||
Status: status,
|
||||
FromUserName: openId,
|
||||
} = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(
|
||||
data
|
||||
)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(
|
||||
data
|
||||
)}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'location': {
|
||||
evt = `用户${FromUserName}上传了地理位置信息`;
|
||||
break;
|
||||
}
|
||||
case 'click': {
|
||||
setClickEventKey(FromUserName, EventKey!, context);
|
||||
evt = `用户${FromUserName}点击菜单【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'view': {
|
||||
evt = `用户${FromUserName}点击菜单跳转链接【${EventKey}】`;
|
||||
break;
|
||||
}
|
||||
case 'templatesendjobfinish': {
|
||||
// 模板消息发送完成,去更新对应的messageSent对象
|
||||
// 这个在线上测试没法通过,返回的msgId不符合,不知道为什么
|
||||
const {
|
||||
MsgID: msgId,
|
||||
Status: status,
|
||||
FromUserName: openId,
|
||||
} = data;
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(
|
||||
data
|
||||
)}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
evt = `应用${appId}的用户${FromUserName}发来了${Event}事件,内容是${JSON.stringify(
|
||||
data
|
||||
)}`;
|
||||
break;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
return {
|
||||
content: '',
|
||||
contentType: 'application/text',
|
||||
};
|
||||
}
|
||||
|
||||
assert(MsgType);
|
||||
// 接收普通消息
|
||||
|
||||
const content =
|
||||
'<xml>' +
|
||||
`<ToUserName>${FromUserName}</ToUserName>` +
|
||||
|
|
@ -692,8 +693,8 @@ async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC) {
|
|||
`<CreateTime>${CreateTime}</CreateTime>` +
|
||||
'<MsgType>transfer_customer_service</MsgType>' +
|
||||
'</xml>';
|
||||
|
||||
const { Content, Title, Description, Url, PicUrl } = data;
|
||||
|
||||
const { Content, Title, Description, Url, PicUrl } = data;
|
||||
|
||||
switch (MsgType) {
|
||||
case 'text': {
|
||||
|
|
@ -713,15 +714,25 @@ async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
createSession(
|
||||
{ data, type: 'wechatPublic', entity: 'application', entityId: appId },
|
||||
context
|
||||
);
|
||||
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(evt);
|
||||
}
|
||||
try {
|
||||
await createSession(
|
||||
{
|
||||
data,
|
||||
type: 'wechatPublic',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
},
|
||||
context
|
||||
);
|
||||
} catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content,
|
||||
contentType: 'application/xml',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content,
|
||||
|
|
@ -731,18 +742,25 @@ async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC) {
|
|||
|
||||
async function onWeChatMpEvent(data: WechatMpEventData, context: BRC) {
|
||||
const appId = context.getApplicationId();
|
||||
createSession(
|
||||
{
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
},
|
||||
context
|
||||
);
|
||||
return {
|
||||
content: 'success'
|
||||
try {
|
||||
await createSession(
|
||||
{
|
||||
data,
|
||||
type: 'wechatMp',
|
||||
entity: 'application',
|
||||
entityId: appId,
|
||||
},
|
||||
context
|
||||
);
|
||||
} catch (err) {
|
||||
// todo 出错的话怎么处理 by wkj
|
||||
return {
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
return {
|
||||
content: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
const endpoints: Record<string, Endpoint<EntityDict, BRC>> = {
|
||||
|
|
@ -753,7 +771,7 @@ const endpoints: Record<string, Endpoint<EntityDict, BRC>> = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -779,7 +797,7 @@ const endpoints: Record<string, Endpoint<EntityDict, BRC>> = {
|
|||
);
|
||||
const { appId } = params;
|
||||
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr')!;
|
||||
return echostr;
|
||||
|
|
@ -823,7 +841,7 @@ const endpoints: Record<string, Endpoint<EntityDict, BRC>> = {
|
|||
params: ['appId'],
|
||||
fn: async (context, params, headers, req, body) => {
|
||||
const { appId } = params;
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
console.log(JSON.stringify(body));
|
||||
return '';
|
||||
|
|
@ -857,7 +875,7 @@ const endpoints: Record<string, Endpoint<EntityDict, BRC>> = {
|
|||
);
|
||||
const { appId } = params;
|
||||
|
||||
if (!appId || appId === '20230210') {
|
||||
if (!appId) {
|
||||
console.error('applicationId参数不存在');
|
||||
const echostr = searchParams.get('echostr')!;
|
||||
return echostr;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export interface Schema extends EntityShape {
|
|||
application: Application;
|
||||
session: Session;
|
||||
user?: User;
|
||||
wechatUser?: WechatUser;
|
||||
wechatUser?: WechatUser; //表示微信客服消息回调服务器传过来
|
||||
createTime?: Datetime;
|
||||
type: Type;
|
||||
text?: Text;
|
||||
|
|
@ -29,7 +29,6 @@ export interface Schema extends EntityShape {
|
|||
link?: String<128>;
|
||||
aaoe?: Boolean; // as agent of entity
|
||||
extra?: Object;
|
||||
openId?: String<32>; //openId存在 表示微信客服消息回调服务器传过来的
|
||||
};
|
||||
|
||||
const entityDesc: EntityDesc<Schema, '', '', {}> = {
|
||||
|
|
@ -48,7 +47,6 @@ const entityDesc: EntityDesc<Schema, '', '', {}> = {
|
|||
link: '图文',
|
||||
aaoe: '作为实体的发起者',
|
||||
extra: '额外信息',
|
||||
openId: '微信用户openId',
|
||||
},
|
||||
v: {
|
||||
type: {
|
||||
|
|
|
|||
|
|
@ -170,12 +170,12 @@ export class ExtraFile2<
|
|||
if (this.files[id]) {
|
||||
const { file } = this.files[id];
|
||||
if (typeof file === 'string') {
|
||||
return file;
|
||||
return file
|
||||
}
|
||||
if (file instanceof File) {
|
||||
return getFileURL(file);
|
||||
}
|
||||
return file;
|
||||
assert(false, 'the incoming file is not supported');
|
||||
}
|
||||
const { origin } = extraFile;
|
||||
const cos = getCos<ED, Cxt, FrontCxt>(origin);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ export type OpSchema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
export type Schema = EntityShape & {
|
||||
|
|
@ -37,7 +36,6 @@ export type Schema = EntityShape & {
|
|||
link?: String<128> | null;
|
||||
aaoe?: Boolean | null;
|
||||
extra?: Object | null;
|
||||
openId?: String<32> | null;
|
||||
application: Application.Schema;
|
||||
session: Session.Schema;
|
||||
user?: User.Schema | null;
|
||||
|
|
@ -66,7 +64,6 @@ type AttrFilter = {
|
|||
link: Q_StringValue;
|
||||
aaoe: Q_BooleanValue;
|
||||
extra: Object;
|
||||
openId: Q_StringValue;
|
||||
extraFile$entity: ExtraFile.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
|
|
@ -91,7 +88,6 @@ export type Projection = {
|
|||
link?: number;
|
||||
aaoe?: number;
|
||||
extra?: number | Object;
|
||||
openId?: number;
|
||||
extraFile$entity?: ExtraFile.Selection & {
|
||||
$entity: "extraFile";
|
||||
};
|
||||
|
|
@ -148,8 +144,6 @@ export type SortAttr = {
|
|||
link: number;
|
||||
} | {
|
||||
aaoe: number;
|
||||
} | {
|
||||
openId: number;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
} | OneOf<ExprOp<OpAttr | string>>;
|
||||
|
|
|
|||
|
|
@ -43,12 +43,6 @@ export const desc: StorageDesc<OpSchema> = {
|
|||
},
|
||||
extra: {
|
||||
type: "object"
|
||||
},
|
||||
openId: {
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
}
|
||||
}
|
||||
},
|
||||
actionType: "crud",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"name":"消息","attr":{"application":"应用","session":"会话","user":"用户","wechatUser":"微信用户","createTime":"发送时间","type":"消息类型","text":"文本内容","files":"文件","link":"图文","aaoe":"作为实体的发起者","extra":"额外信息","openId":"微信用户openId"},"v":{"type":{"text":"文字","image":"图片","voice":"音频","video":"视频","link":"图文","location":"位置","event":"事件","miniprogrampage":"小程序"}}}
|
||||
{"name":"消息","attr":{"application":"应用","session":"会话","user":"用户","wechatUser":"微信用户","createTime":"发送时间","type":"消息类型","text":"文本内容","files":"文件","link":"图文","aaoe":"作为实体的发起者","extra":"额外信息"},"v":{"type":{"text":"文字","image":"图片","voice":"音频","video":"视频","link":"图文","location":"位置","event":"事件","miniprogrampage":"小程序"}}}
|
||||
|
|
@ -126,7 +126,6 @@ const triggers: Trigger<
|
|||
createTime: 1,
|
||||
$$createAt$$: 1,
|
||||
aaoe: 1,
|
||||
openId: 1,
|
||||
},
|
||||
filter: {
|
||||
sessionId,
|
||||
|
|
@ -151,7 +150,7 @@ const triggers: Trigger<
|
|||
},
|
||||
{}
|
||||
);
|
||||
if (sessionMessage && sessionMessage.openId) {
|
||||
if (sessionMessage && sessionMessage.wechatUserId) {
|
||||
const [session] = await context.select(
|
||||
'session',
|
||||
{
|
||||
|
|
@ -208,12 +207,13 @@ const triggers: Trigger<
|
|||
appSecret
|
||||
) as WechatPublicInstance;
|
||||
}
|
||||
const openId = sessionMessage.wechatUser!.openId!;
|
||||
|
||||
//微信发送客服消息
|
||||
switch (msgType) {
|
||||
case 'text': {
|
||||
await wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId!,
|
||||
openId,
|
||||
type: msgType,
|
||||
content: text!,
|
||||
});
|
||||
|
|
@ -225,12 +225,11 @@ const triggers: Trigger<
|
|||
if (extraFile) {
|
||||
const mediaId = extraFile.extra1!;
|
||||
wechatInstance.sendServeMessage({
|
||||
openId: sessionMessage.openId!,
|
||||
openId,
|
||||
type: msgType,
|
||||
mediaId,
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue