5
5
const debug = require ( "debug" ) ( "sync:ctrl:w3" ) ;
6
6
const utils = require ( "../utils/index" ) ;
7
7
const feishuService = require ( "../services/feishu.service" ) ;
8
-
9
-
8
+ const mailService = require ( "../services/email.service" ) ;
10
9
11
10
function Controller ( ) {
12
11
@@ -19,66 +18,79 @@ function Controller() {
19
18
* @param {* } body
20
19
*/
21
20
Controller . prototype . handleW3broadcast = async function ( headers , params , body ) {
22
- let ret = { "msg" : "done" } ;
23
- /**
24
- * sync:routes:w3 /broadcast ctx.params {} , body
21
+ let ret = { "msg" : "done" } ;
22
+ /**
23
+ * sync:routes:w3 /broadcast ctx.params {} , body
25
24
{
26
- "link": "https://www.cskefu.com/2022/10/08/test-c/",
27
- "post_title": "Test C",
28
- "author_id": "99",
29
- "display_name": "Hai",
30
- "user_email": "h@cskefu .com",
31
- "user_profile": "https://www.cskefu.com/user/99/",
32
- "categories": [
33
- {
34
- "term_id": 118,
35
- "name": "业务观点",
36
- "slug": "business",
37
- "term_group": 0,
38
- "term_taxonomy_id": 118,
39
- "taxonomy": "category",
40
- "description": "业务、产品及服务的应用和解决方案:呼叫中心、联络中心、智能客服、客服机器人、CTI、云计算等。有价值的干货:应用场景、业务价
25
+ "link": "https://www.cskefu.com/2022/10/08/test-c/",
26
+ "post_title": "Test C",
27
+ "author_id": "99",
28
+ "display_name": "Hai",
29
+ "user_email": "h@cskefu .com",
30
+ "user_profile": "https://www.cskefu.com/user/99/",
31
+ "categories": [
32
+ {
33
+ "term_id": 118,
34
+ "name": "业务观点",
35
+ "slug": "business",
36
+ "term_group": 0,
37
+ "term_taxonomy_id": 118,
38
+ "taxonomy": "category",
39
+ "description": "业务、产品及服务的应用和解决方案:呼叫中心、联络中心、智能客服、客服机器人、CTI、云计算等。有价值的干货:应用场景、业务价
41
40
值、创新方案。",
42
- "parent": 0,
43
- "count": 12,
44
- "filter": "raw",
45
- "cat_ID": 118,
46
- "category_count": 12,
47
- "category_description": "业务、产品及服务的应用和解决方案:呼叫中心、联络中心、智能客服、客服机器人、CTI、云计算等。有价值的干货:应用场
41
+ "parent": 0,
42
+ "count": 12,
43
+ "filter": "raw",
44
+ "cat_ID": 118,
45
+ "category_count": 12,
46
+ "category_description": "业务、产品及服务的应用和解决方案:呼叫中心、联络中心、智能客服、客服机器人、CTI、云计算等。有价值的干货:应用场
48
47
景、业务价值、创新方案。",
49
- "cat_name": "业务观点",
50
- "category_nicename": "business",
51
- "category_parent": 0
52
- },
53
- {
54
- "term_id": 145,
55
- "name": "产品专栏",
56
- "slug": "product",
57
- "term_group": 0,
58
- "term_taxonomy_id": 145,
59
- "taxonomy": "category",
60
- "description": "产品理念、产品设计、产品构想等;主要由春松客服产品经理或产品办公室发布。",
61
- "parent": 0,
62
- "count": 2,
63
- "filter": "raw",
64
- "cat_ID": 145,
65
- "category_count": 2,
66
- "category_description": "产品理念、产品设计、产品构想等;主要由春松客服产品经理或产品办公室发布。",
67
- "cat_name": "产品专栏",
68
- "category_nicename": "product",
69
- "category_parent": 0
70
- }
71
- ]
48
+ "cat_name": "业务观点",
49
+ "category_nicename": "business",
50
+ "category_parent": 0
51
+ },
52
+ {
53
+ "term_id": 145,
54
+ "name": "产品专栏",
55
+ "slug": "product",
56
+ "term_group": 0,
57
+ "term_taxonomy_id": 145,
58
+ "taxonomy": "category",
59
+ "description": "产品理念、产品设计、产品构想等;主要由春松客服产品经理或产品办公室发布。",
60
+ "parent": 0,
61
+ "count": 2,
62
+ "filter": "raw",
63
+ "cat_ID": 145,
64
+ "category_count": 2,
65
+ "category_description": "产品理念、产品设计、产品构想等;主要由春松客服产品经理或产品办公室发布。",
66
+ "cat_name": "产品专栏",
67
+ "category_nicename": "product",
68
+ "category_parent": 0,
69
+ "content": "Formatted HTML, https://www.kevinleary.net/get-wordpress-post-content-by-post-id/"
70
+ }
71
+ ]
72
72
}
73
- */
74
- utils . writeTmpOutputFileOnDevelopment ( body ) ;
73
+ */
74
+ utils . writeTmpOutputFileOnDevelopment ( body ) ;
75
75
76
- // 发送 W3 文章通知到飞书群
76
+ // 发送 W3 文章通知到飞书群
77
+ try {
77
78
await feishuService . sendW3BroadcastNotification ( body ) ;
79
+ } catch ( e ) {
80
+ console . log ( "[Error] feishuService.sendW3BroadcastNotification" )
81
+ console . error ( e ) ;
82
+ }
78
83
84
+ // 发送 W3 文章通知到邮件列表服务
85
+ try {
86
+ await mailService . sendW3BroadcastMaillists ( body ) ;
87
+ } catch ( e ) {
88
+ console . log ( "[Error] mailService.sendW3BroadcastMaillists" )
89
+ console . error ( e ) ;
90
+ }
79
91
80
- debug ( "[handleW3broadcast] ret" , JSON . stringify ( ret ) )
81
- return ret ;
92
+ debug ( "[handleW3broadcast] ret" , JSON . stringify ( ret ) )
93
+ return ret ;
82
94
}
83
95
84
96
0 commit comments