-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create plain-text transform to cover the HipChat and Flowdock transform #125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are a big improvement! I mostly have questions on the changes.
@@ -54,7 +54,7 @@ export default class AlertsListener extends Listener { | |||
let time = msg.time; | |||
|
|||
this.client.Alerts.getFilteredAlerts(status, state, time).then((res) => { | |||
if (res.count === 0) { | |||
if (res.members.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this here? Using the res.count is probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically because the response does not have the count attribute, it has only a member array.
src/listener/ov-listener.js
Outdated
@@ -62,7 +62,15 @@ export default function(robot, client) { | |||
|
|||
let checkedMessage = filter.check(resource); | |||
if (typeof checkedMessage !== 'undefined' && checkedMessage.length > 0) { | |||
transform.messageRoom(client.notificationsRoom, resource.resource); | |||
let room = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you shorten this to:
let room = '#' + client.notificationsRoom;
if (robot.adapterName === 'flowdock') {
room = client.notificationsRoom;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, fixed.
if (res.count === 0) { | ||
return this.transform.text(msg, msg.message.user.name + ", I didn't find any blades with a " + msg.status.toLowerCase() + " status."); | ||
|
||
if (res.members.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to change line 183?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we do. See the comment above.
src/listener/server-hardware.js
Outdated
if (msg.status.toLowerCase() === "ok") { | ||
return this.transform.send(msg, res, "Okay " + msg.message.user.name + ", the following blades have an " + msg.status.toUpperCase() + " status."); | ||
if (status.toLowerCase() === "ok") { | ||
return this.transform.send(msg, res, "Okay " + msg.message.user.name + ", the following blades have an " + status.toLowerCase() + " status."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why lower case on the status in the message to the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
@@ -198,7 +199,7 @@ export default class ServerHardwareListener extends Listener { | |||
let status = msg.powerState.substring(8, msg.powerState.length); | |||
status = status.charAt(0).toUpperCase() + status.slice(1); | |||
this.client.ServerHardware.getHardwareByPowerState(status).then((res) => { | |||
if (res.count === 0) { | |||
if (res.members.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see the comment above.
@@ -81,7 +81,7 @@ export default class ServerProfilesListener extends Listener { | |||
let status = msg.status.toLowerCase(); | |||
status = status.charAt(0).toUpperCase() + status.slice(1); | |||
this.client.ServerProfiles.getProfilesByStatus(status).then((res) => { | |||
if (res.count === 0) { | |||
if (res.members.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see the comment above.
return 'Flowdock'; | ||
} else { | ||
return 'HipChat'; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this file just plain-text.js? No need to include transformer in the name of the file, this will match the slack and shell transformers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, fixed!
@@ -77,7 +77,10 @@ function output(resource) { | |||
return []; | |||
} | |||
|
|||
export default class FlowdockTransform { | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think JS multi-line comments are just /* */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
@@ -100,8 +103,8 @@ export default class FlowdockTransform { | |||
|
|||
const out = output(resource).join('\n'); | |||
if (text) { | |||
msg.send(out); | |||
} | |||
msg.send(text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we supposed to use out in the msg.send()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we are using yet.
Before:
if (text) {
msg.send(out);
}
msg.send(out);
After:
if (text) {
msg.send(text);
}
msg.send(out);
The bug was fixed, because before the output was being shown 2 times and the text never.
…ent fixed, and improving the if statement to get the right room
Closes #124.