File tree Expand file tree Collapse file tree 6 files changed +28
-26
lines changed Expand file tree Collapse file tree 6 files changed +28
-26
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ The following parameters can be set in config files or in env variables:
28
28
if not provided, then SSL connection is not used, direct insecure connection is used;
29
29
if provided, it can be either path to private key file or private key content
30
30
- BUS_API_BASE_URL: Bus API url
31
- - BUS_API_AUTH_TOKEN: Bus API auth token
32
31
- REPLY_EMAIL_PREFIX: prefix of the genereated reply email address
33
32
- REPLY_EMAIL_DOMAIN: email domain
34
33
- DEFAULT_REPLY_EMAIL: default reply to email address, for example no-reply@topcoder.com
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ module.exports = {
27
27
KAFKA_CLIENT_CERT_KEY : process . env . KAFKA_CLIENT_CERT_KEY ?
28
28
process . env . KAFKA_CLIENT_CERT_KEY . replace ( '\\n' , '\n' ) : null ,
29
29
30
- BUS_API_AUTH_TOKEN : process . env . BUS_API_AUTH_TOKEN ,
31
30
MENTION_EMAIL : process . env . MENTION_EMAIL ,
32
31
REPLY_EMAIL_PREFIX : process . env . REPLY_EMAIL_PREFIX ,
33
32
REPLY_EMAIL_DOMAIN : process . env . REPLY_EMAIL_DOMAIN ,
@@ -37,7 +36,7 @@ module.exports = {
37
36
TC_API_V3_BASE_URL : process . env . TC_API_V3_BASE_URL || 'https://api.topcoder-dev.com/v3' ,
38
37
TC_API_V4_BASE_URL : process . env . TC_API_V4_BASE_URL || 'https://api.topcoder-dev.com/v4' ,
39
38
TC_API_V5_BASE_URL : process . env . TC_API_V5_BASE_URL || 'https://api.topcoder-dev.com/v5' ,
40
- MESSAGE_API_BASE_URL : process . env . MESSAGE_API_BASE_URL || 'https://api.topcoder-dev.com/v4 ' ,
39
+ MESSAGE_API_BASE_URL : process . env . MESSAGE_API_BASE_URL || 'https://api.topcoder-dev.com/v5 ' ,
41
40
ENABLE_EMAILS : process . env . ENABLE_EMAILS || true ,
42
41
ENABLE_DEV_MODE : process . env . ENABLE_DEV_MODE || true ,
43
42
DEV_MODE_EMAIL : process . env . DEV_MODE_EMAIL ,
Original file line number Diff line number Diff line change 4
4
const request = require ( 'superagent' ) ;
5
5
const config = require ( 'config' ) ;
6
6
const _ = require ( 'lodash' ) ;
7
- const tcCoreLibAuth = require ( 'tc-core-library-js' ) . auth ;
8
- const m2m = tcCoreLibAuth . m2m ( config ) ;
9
7
10
8
/**
11
9
* Get project details
@@ -70,7 +68,7 @@ const getRoleMembers = (roleId) => request
70
68
*/
71
69
const getUsersById = ( ids ) => {
72
70
const query = _ . map ( ids , ( id ) => 'userId:' + id ) . join ( ' OR ' ) ;
73
- return m2m . getMachineToken ( config . AUTH0_CLIENT_ID , config . AUTH0_CLIENT_SECRET )
71
+ return M2m . getMachineToken ( config . AUTH0_CLIENT_ID , config . AUTH0_CLIENT_SECRET )
74
72
. then ( ( token ) => {
75
73
if ( ! token && config . TC_ADMIN_TOKEN ) token = config . TC_ADMIN_TOKEN ;
76
74
@@ -108,7 +106,7 @@ const getUsersById = (ids) => {
108
106
*/
109
107
const getUsersByHandle = ( handles ) => {
110
108
const query = _ . map ( handles , ( handle ) => 'handle:' + handle ) . join ( ' OR ' ) ;
111
- return m2m . getMachineToken ( config . AUTH0_CLIENT_ID , config . AUTH0_CLIENT_SECRET )
109
+ return M2m . getMachineToken ( config . AUTH0_CLIENT_ID , config . AUTH0_CLIENT_SECRET )
112
110
. then ( ( token ) => {
113
111
if ( ! token && config . TC_ADMIN_TOKEN ) token = config . TC_ADMIN_TOKEN ;
114
112
Original file line number Diff line number Diff line change @@ -47,7 +47,6 @@ PORT=$(eval "echo \$${ENV}_PORT")
47
47
48
48
# email notifications config
49
49
ENABLE_EMAILS=$( eval " echo \$ ${ENV} _ENABLE_EMAILS" )
50
- BUS_API_AUTH_TOKEN=$( eval " echo \$ ${ENV} _BUS_API_AUTH_TOKEN" )
51
50
MENTION_EMAIL=$( eval " echo \$ ${ENV} _MENTION_EMAIL" )
52
51
REPLY_EMAIL_PREFIX=$( eval " echo \$ ${ENV} _REPLY_EMAIL_PREFIX" )
53
52
REPLY_EMAIL_DOMAIN=$( eval " echo \$ ${ENV} _REPLY_EMAIL_DOMAIN" )
@@ -212,10 +211,6 @@ make_task_def(){
212
211
"name": "DEV_MODE_EMAIL",
213
212
"value": "%s"
214
213
},
215
- {
216
- "name": "BUS_API_AUTH_TOKEN",
217
- "value": "%s"
218
- },
219
214
{
220
215
"name": "LOG_LEVEL",
221
216
"value": "%s"
@@ -271,7 +266,7 @@ make_task_def(){
271
266
}
272
267
]'
273
268
274
- task_def=$( printf " $task_template " $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV " $KAFKA_CLIENT_CERT " " $KAFKA_CLIENT_CERT_KEY " $KAFKA_GROUP_ID " $KAFKA_TOPIC_IGNORE_PREFIX " $KAFKA_URL $DATABASE_URL $AUTHSECRET " $AUTHDOMAIN " " $JWKSURI " $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $TC_ADMIN_TOKEN $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $ENABLE_DEV_MODE $DEV_MODE_EMAIL $BUS_API_AUTH_TOKEN $ LOG_LEVEL $VALID_ISSUERS $PORT " $API_CONTEXT_PATH " " $AUTH0_URL " " $AUTH0_AUDIENCE " $AUTH0_CLIENT_ID " $AUTH0_CLIENT_SECRET " $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV )
269
+ task_def=$( printf " $task_template " $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV " $KAFKA_CLIENT_CERT " " $KAFKA_CLIENT_CERT_KEY " $KAFKA_GROUP_ID " $KAFKA_TOPIC_IGNORE_PREFIX " $KAFKA_URL $DATABASE_URL $AUTHSECRET " $AUTHDOMAIN " " $JWKSURI " $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $TC_ADMIN_TOKEN $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $ENABLE_DEV_MODE $DEV_MODE_EMAIL $LOG_LEVEL $VALID_ISSUERS $PORT " $API_CONTEXT_PATH " " $AUTH0_URL " " $AUTH0_AUDIENCE " $AUTH0_CLIENT_ID " $AUTH0_CLIENT_SECRET " $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV )
275
270
}
276
271
277
272
register_definition () {
Original file line number Diff line number Diff line change 6
6
const config = require ( 'config' ) ;
7
7
const _ = require ( 'lodash' ) ;
8
8
const errors = require ( './src/common/errors' ) ;
9
+ const tcCoreLibAuth = require ( 'tc-core-library-js' ) . auth ;
10
+ global . M2m = tcCoreLibAuth . m2m ( config ) ;
9
11
10
12
// key is topic name, e.g. 'notifications.connect.project.created';
11
13
// value is handler for the topic to find user ids that should receive notifications for a message,
Original file line number Diff line number Diff line change @@ -9,19 +9,28 @@ const _ = require('lodash');
9
9
*
10
10
* @return {Promise } promise resolved to post event
11
11
*/
12
- const postEvent = ( event ) => request
13
- . post ( `${ config . TC_API_V5_BASE_URL } /bus/events` )
14
- . set ( 'Content-Type' , 'application/json' )
15
- . set ( 'Authorization' , `Bearer ${ config . BUS_API_AUTH_TOKEN } ` )
16
- . send ( event )
17
- . then ( ( ) => '' )
18
- . catch ( ( err ) => {
19
- const errorDetails = _ . get ( err , 'message' ) ;
20
- throw new Error (
21
- `Failed to post event ${ event } .` +
22
- ( errorDetails ? ' Server response: ' + errorDetails : '' )
23
- ) ;
24
- } ) ;
12
+ const postEvent = ( event ) => {
13
+ return M2m . getMachineToken ( config . AUTH0_CLIENT_ID , config . AUTH0_CLIENT_SECRET )
14
+ . then ( ( token ) => {
15
+ return request
16
+ . post ( `${ config . TC_API_V5_BASE_URL } /bus/events` )
17
+ . set ( 'Content-Type' , 'application/json' )
18
+ . set ( 'Authorization' , `Bearer ${ token } ` )
19
+ . send ( event )
20
+ . then ( ( ) => '' )
21
+ . catch ( ( err ) => {
22
+ const errorDetails = _ . get ( err , 'message' ) ;
23
+ throw new Error (
24
+ `Failed to post event ${ event } .` +
25
+ ( errorDetails ? ' Server response: ' + errorDetails : '' )
26
+ ) ;
27
+ } ) ;
28
+ } )
29
+ . catch ( ( err ) => {
30
+ err . message = 'Error generating m2m token: ' + err . message ;
31
+ throw err ;
32
+ } ) ;
33
+ }
25
34
26
35
module . exports = {
27
36
postEvent,
You can’t perform that action at this time.
0 commit comments