Skip to content

Commit

Permalink
Update getRoomIdFromName- return null if not found
Browse files Browse the repository at this point in the history
Remove dependency on robot adapter findFlows since it will always
return something - by default, the identifier passed to it - even
if a flow is not found

All callers appear to handle the possibility of this returning null
  • Loading branch information
kb0rg committed Jul 4, 2019
1 parent 3ef9ad1 commit b5bf00c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/flowdock-util.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// A collection of adapter-helpers for hubot on flowdock

function getRoomIdFromName(robot, roomName) {
if (!robot.adapter.flows || !robot.adapter.findFlow) {
// in some cases, returning the room name will bork things, so we should log
robot.logger.info(`getRoomIdFromName couldn't find flow id for ${roomName}`)
return roomName
if (!robot.adapter.flows) {
return
}
for (let flow of robot.adapter.flows || []) {
if (roomName.toLowerCase() === flow.name.toLowerCase()) {
return flow.id
}
}
return robot.adapter.findFlow(roomName)
}

function getRoomNameFromId(robot, roomId) {
Expand Down

0 comments on commit b5bf00c

Please sign in to comment.