diff --git a/src/adapter.coffee b/src/adapter.coffee index dab2a2f..785a38d 100644 --- a/src/adapter.coffee +++ b/src/adapter.coffee @@ -86,8 +86,8 @@ class SymphonyAdapter extends Adapter @robot.userId = response.userId @symphony.getUser(response.userId) .then (response) => - @robot.displayName = response.userAttributes?.displayName - @robot.logger.info "Connected as #{response.userAttributes?.displayName} [#{response.userSystemInfo?.status}]" + @robot.displayName = response.displayName + @robot.logger.info "Connected as #{response.displayName}" .fail (err) => @robot.emit 'error', new Error("Unable to resolve identity: #{err}") hourlyRefresh = memoize @_getUser, {maxAge: 3600000, length: 2} @@ -131,9 +131,9 @@ class SymphonyAdapter extends Adapter .then (response) => # record basic user details in hubot's brain, setting the room causes the brain to update each time we're seen in a new conversation existing = @robot.brain.userForId(userId) - existing['name'] = response.userAttributes?.userName - existing['displayName'] = response.userAttributes?.displayName - existing['emailAddress'] = response.userAttributes?.emailAddress + existing['name'] = response.userName + existing['displayName'] = response.displayName + existing['emailAddress'] = response.emailAddress existing['room'] = streamId @robot.brain.userForId(userId, existing) existing diff --git a/src/diagnostic.coffee b/src/diagnostic.coffee index bf98bfb..383bf38 100644 --- a/src/diagnostic.coffee +++ b/src/diagnostic.coffee @@ -57,7 +57,7 @@ userId = symphony.whoAmI() logger.info "UserId: #{response.userId}" symphony.getUser(response.userId) .then (response) => - logger.info "My name is #{response.userAttributes?.displayName} [#{response.userAttributes?.emailAddress}] and I'm #{response.userSystemInfo?.status}" + logger.info "My name is #{response.displayName} [#{response.emailAddress}]" .fail (err) => logger.error "Failed to fetch userId: #{err}" .done diff --git a/src/symphony.coffee b/src/symphony.coffee index f9f4dc5..8581cba 100644 --- a/src/symphony.coffee +++ b/src/symphony.coffee @@ -43,23 +43,23 @@ class Symphony @_httpPodGet('/pod/v1/sessioninfo', true) getUser: (userId) => - @_httpPodGet('/pod/v1/admin/user/' + userId, true) + @_httpPodGet("/pod/v2/user?uid=#{userId}&local=true", true) sendMessage: (streamId, message, format) => body = { message: message format: format } - @_httpAgentPost('/agent/v2/stream/' + streamId + '/message/create', true, body) + @_httpAgentPost("/agent/v2/stream/#{streamId}/message/create", true, body) getMessages: (streamId, since, limit = 100) => - @_httpAgentGet('/agent/v2/stream/' + streamId + '/message', true) + @_httpAgentGet("/agent/v2/stream/#{streamId}/message", true) createDatafeed: => @_httpAgentPost('/agent/v1/datafeed/create', true) readDatafeed: (datafeedId) => - @_httpAgentGet('/agent/v2/datafeed/' + datafeedId + '/read', false) + @_httpAgentGet("/agent/v2/datafeed/#{datafeedId}/read", false) _httpPodGet: (path, failUnlessHttp200) => @sessionAuth().then (value) => diff --git a/test/nock-server.coffee b/test/nock-server.coffee index f876a13..88f4a5b 100644 --- a/test/nock-server.coffee +++ b/test/nock-server.coffee @@ -83,31 +83,23 @@ class NockServer extends EventEmitter .reply(200, { userId: @botUserId }) - .get('/pod/v1/admin/user/' + @realUserId) + .get("/pod/v2/user?uid=#{@realUserId}&local=true") .reply(200, { - userAttributes: { - emailAddress: 'johndoe@symphony.com' - firstName: 'John' - lastName: 'Doe' - userName: 'johndoe' - displayName: 'John Doe' - } - userSystemInfo: { - id: @realUserId - } + id: @realUserId + emailAddress: 'johndoe@symphony.com' + firstName: 'John' + lastName: 'Doe' + userName: 'johndoe' + displayName: 'John Doe' }) - .get('/pod/v1/admin/user/' + @botUserId) + .get("/pod/v2/user?uid=#{@botUserId}&local=true") .reply(200, { - userAttributes: { - emailAddress: 'mozart@symphony.com' - firstName: 'Wolfgang Amadeus' - lastName: 'Mozart' - userName: 'mozart' - displayName: 'Mozart' - } - userSystemInfo: { - id: @realUserId - } + id: @realUserId + emailAddress: 'mozart@symphony.com' + firstName: 'Wolfgang Amadeus' + lastName: 'Mozart' + userName: 'mozart' + displayName: 'Mozart' }) @agentScope = nock(@host) @@ -116,7 +108,7 @@ class NockServer extends EventEmitter .matchHeader('keyManagerToken', 'KEY_MANAGER_TOKEN') .post('/agent/v1/util/echo') .reply(200, (uri, requestBody) -> requestBody) - .post('/agent/v2/stream/' + @streamId + '/message/create') + .post("/agent/v2/stream/#{@streamId}/message/create") .reply(200, (uri, requestBody) => message = { id: uuid.v1() @@ -130,7 +122,7 @@ class NockServer extends EventEmitter @_receiveMessage message message ) - .get('/agent/v2/stream/' + @streamId + '/message') + .get("/agent/v2/stream/#{@streamId}/message") .reply(200, (uri, requestBody) => JSON.stringify(@messages)) .post('/agent/v1/datafeed/create') .reply (uri, requestBody) => @@ -140,7 +132,7 @@ class NockServer extends EventEmitter [200, JSON.stringify { id: @datafeedId }] - .get('/agent/v2/datafeed/' + @datafeedId + '/read') + .get("/agent/v2/datafeed/#{@datafeedId}/read") .reply (uri, requestBody) => if @datafeedReadHttp400Count-- > 0 [400, null] diff --git a/test/symphony-test.coffee b/test/symphony-test.coffee index 531a399..304a239 100644 --- a/test/symphony-test.coffee +++ b/test/symphony-test.coffee @@ -70,7 +70,7 @@ describe 'REST API test suite', () -> it 'getUser should expose user details', () -> symphony.getUser(nock.realUserId) .then (response) -> - assert.equal('johndoe@symphony.com', response.userAttributes.emailAddress) + assert.equal('johndoe@symphony.com', response.emailAddress) .fail (error) -> assert.fail(0, 1,"Failed with error #{error}")