Skip to content

Commit

Permalink
Added RECORDING_CREATED event
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Jul 29, 2020
1 parent 5684d7d commit f938dd7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions mods/voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"dependencies": {
"@fonos/logger": "^0.0.29",
"@fonos/events": "^0.0.29",
"@fonos/tts": "^0.0.29",
"objectid": "^3.2.1"
}
Expand Down
16 changes: 16 additions & 0 deletions mods/voice/src/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { EventsSender } from '@fonos/events'
import logger from '@fonos/logger'

let instance: any

try {
if (!process.env.EVENTS_BROKERS)
throw 'core.common.events [environment variable EVENTS_BROKERS not set]'
const brokers = process.env.EVENTS_BROKERS.split(',')
instance = new EventsSender(brokers, process.env.EVENTS_QUEUE)
instance.connect()
} catch (e) {
logger.error(e)
}

export default instance
5 changes: 5 additions & 0 deletions mods/voice/src/record.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Verb from './verb'
import events from './events'

const objectid = require('objectid')

Expand Down Expand Up @@ -68,6 +69,10 @@ class Record extends Verb {
this.config.bucket
)

events.sendToQ('RECORDING_CREATED', {
filename
})

return {
keyPressed: res.attributes.result,
recordingUri,
Expand Down
3 changes: 2 additions & 1 deletion mods/voice/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
},
"references": [
{ "path": "../tts" },
{ "path": "../logger" }
{ "path": "../logger" },
{ "path": "../events" }
],
"exclude": [
"node_modules",
Expand Down

0 comments on commit f938dd7

Please sign in to comment.