Skip to content

v1.3 #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 16, 2021
Merged

v1.3 #54

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"urlcode": "$ { challenge.id }",
"group": {
"name": "${ challenge.name }",
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this forum, thanks!",
"description": "Welcome to ${ challenge.name }.\nPlease post your questions in this forum, thank you!",
"privacy": "secret",
"type": "challenge"
},
Expand Down Expand Up @@ -57,7 +57,7 @@
"urlcode": "$ { challenge.id }",
"group": {
"name": "${ challenge.name }",
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
"description": "Welcome to ${ challenge.name }.\nPlease post your questions in this forum, thank you!",
"privacy": "secret",
"type": "challenge"
},
Expand Down Expand Up @@ -106,7 +106,7 @@
"urlcode": "$ { challenge.id }",
"group": {
"name": "${ challenge.name }",
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
"description": "Welcome to ${ challenge.name }.\nPlease post your questions in this forum, thank you!",
"privacy": "secret",
"type": "challenge"
},
Expand Down Expand Up @@ -149,7 +149,7 @@
"urlcode": "$ { challenge.id }",
"group": {
"name": "${ challenge.name }",
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
"description": "Welcome to ${ challenge.name }.\nPlease post your questions in this forum, thank you!",
"privacy": "secret",
"type": "challenge"
},
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ services:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_CREATE_TOPICS: "challenge.notification.create:1:1,challenge.notification.update:1:1,challenge.notification.events:1:1,challenge.action.resource.create:1:1,challenge.action.resource.delete:1:1"
KAFKA_CREATE_TOPICS: "challenge.notification.create:1:1,challenge.notification.update:1:1,challenge.action.resource.create:1:1,challenge.action.resource.delete:1:1"
192 changes: 4 additions & 188 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions sample-data/challenge.notification.events-registeration.json

This file was deleted.

13 changes: 0 additions & 13 deletions sample-data/challenge.notification.events-unregisteration.json

This file was deleted.

9 changes: 1 addition & 8 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ module.exports = {
CHALLENGE_CREATE_TOPIC: 'challenge.notification.create',
// For challenge update
CHALLENGE_UPDATE_TOPIC: 'challenge.notification.update',
// For member registrations and de-registrations
CHALLENGE_NOTIFICATION_TOPIC: 'challenge.notification.events',
// For co-pilots,PMs,etc.
// For member registrations and de-registrations, co-pilots,PMs,etc.
RESOURCE_CREATE_TOPIC: 'challenge.action.resource.create',
RESOURCE_DELETE_TOPIC: 'challenge.action.resource.delete'
},
// Values of `type` in payload of challenge.notification.events
CHALLENGE_NOTIFICATION_EVENT_TYPES: {
USER_REGISTRATION: 'USER_REGISTRATION',
USER_UNREGISTRATION: 'USER_UNREGISTRATION'
}
},
TEMPLATES: {
Expand Down
17 changes: 5 additions & 12 deletions src/modules/user_management/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,10 @@ if (config.VANILLA_ENABLED) {
services.push(manageVanillaUser)
}

function canProcessEvent (payload, topic) {
if (topic === constants.KAFKA.TOPICS.CHALLENGE_NOTIFICATION_TOPIC) {
const eventTypes = constants.KAFKA.CHALLENGE_NOTIFICATION_EVENT_TYPES
const actionMap = {
[eventTypes.USER_REGISTRATION]: constants.USER_ACTIONS.INVITE,
[eventTypes.USER_UNREGISTRATION]: constants.USER_ACTIONS.KICK
}
if (!(payload.type in actionMap)) {
logger.debug(`Not supported ${payload.type}. Only message types ${JSON.stringify(Object.keys(eventTypes))} are processed from '${topic}'`)
return false
}
function canProcessEvent (topic) {
if (!_.includes([constants.KAFKA.TOPICS.RESOURCE_CREATE_TOPIC, constants.KAFKA.TOPICS.RESOURCE_DELETE_TOPIC], topic)) {
logger.debug('Not supported topic.')
return false
}
return true
}
Expand Down Expand Up @@ -65,7 +58,7 @@ async function handler (messageSet, topic) {
return
}
for (const item of messageSet) {
if (!canProcessEvent(item, topic)) {
if (!canProcessEvent(topic)) {
continue
}
if (_.isArray(item)) {
Expand Down
Loading