Added brain loading for peristent brains
This commit is contained in:
Родитель
2dc57e15d3
Коммит
7a5a541737
|
@ -31,18 +31,20 @@ class BotFrameworkAdapter extends Adapter
|
|||
robot.logger.info "#{LogPrefix} Adapter loaded. Using appId #{@appId}"
|
||||
|
||||
# Initial Admins should be required when auth is enabled
|
||||
if @enableAuth
|
||||
if @initialAdmins?
|
||||
# If there isn't a list of authorized users in the brain, populate
|
||||
# it with admins from the environment variable
|
||||
if robot.brain.get("authorizedUsers") is null
|
||||
robot.logger.info "#{LogPrefix} Restricting by name, setting admins"
|
||||
authorizedUsers = {}
|
||||
for admin in process.env.HUBOT_TEAMS_INITIAL_ADMINS.split(",")
|
||||
authorizedUsers[admin.toLowerCase()] = true
|
||||
robot.brain.set("authorizedUsers", authorizedUsers)
|
||||
else
|
||||
throw new Error("HUBOT_TEAMS_INITIAL_ADMINS is required for authorization")
|
||||
@robot.brain.on( "loaded", () =>
|
||||
if @enableAuth
|
||||
if @initialAdmins?
|
||||
# If there isn't a list of authorized users in the brain, populate
|
||||
# it with admins from the environment variable
|
||||
if robot.brain.get("authorizedUsers") is null
|
||||
robot.logger.info "#{LogPrefix} Restricting by name, setting admins"
|
||||
authorizedUsers = {}
|
||||
for admin in process.env.HUBOT_TEAMS_INITIAL_ADMINS.split(",")
|
||||
authorizedUsers[admin.toLowerCase()] = true
|
||||
robot.brain.set("authorizedUsers", authorizedUsers)
|
||||
else
|
||||
throw new Error("HUBOT_TEAMS_INITIAL_ADMINS is required for authorization")
|
||||
)
|
||||
|
||||
@connector = new BotBuilder.ChatConnector {
|
||||
appId: @appId
|
||||
|
@ -53,7 +55,6 @@ class BotFrameworkAdapter extends Adapter
|
|||
|
||||
@connector.onInvoke (events, cb) => @onInvoke events, cb
|
||||
|
||||
|
||||
# Handles the invoke and passes an event to be handled, if needed
|
||||
onInvoke: (invokeEvent, cb) ->
|
||||
middleware = @using(invokeEvent.source)
|
||||
|
|
|
@ -32,6 +32,8 @@ class MockRobot
|
|||
return null
|
||||
set: (key, value) ->
|
||||
@data[key] = value
|
||||
on: (eventType, functionToRun) ->
|
||||
functionToRun()
|
||||
|
||||
receive: (event) ->
|
||||
@brain.data["event"] = event
|
||||
|
|
Загрузка…
Ссылка в новой задаче