Skip to content

Commit

Permalink
fix: Add an event unique identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexb committed Jan 21, 2018
1 parent 4bdb7b5 commit bf92708
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ app.use(ctx => {
}
})

const events = {}
const events = {
uid: 0
}
const actions = Object.assign(
{},
requireDir('./modules/issues'),
Expand All @@ -65,14 +67,15 @@ Object.keys(pkg.config['github-bot']).forEach(repo => {
const register = events[`${type}/${name}`]
if (config.enabled === true && register) {
register((eventName, callback) => {
githubEvent.on(`${repo}@${eventName}@source`, data => {
const uid = events.uid++
githubEvent.on(`${repo}@${eventName}@source@${uid}`, data => {
callback(data, {
config: pkg.config['github-bot'][repo],
scope: config.data || {}
})
})
githubEvent.on(`${repo}@${eventName}`, data => {
githubEvent.emit(`${repo}@${eventName}@source`, data)
githubEvent.emit(`${repo}@${eventName}@source@${uid}`, data)
})
})
} else if (config.enabled !== true) {
Expand Down

0 comments on commit bf92708

Please sign in to comment.