这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Conversation

@CrackerStealth
Copy link
Contributor

Updated pushover to allow the main pushover call to use default values when not supplied.

Signed-off-by: Chris Graham crackerstealth@gmail.com (github: CrackerStealth)

@CrackerStealth
Copy link
Contributor Author

Helping support the use-case in this thread https://community.openhab.org/t/pushover-action-syntax/23188 , without changing or breaking previous functional uses.

Copy link
Contributor

@9037568 9037568 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the two inline comments, this LGTM.

However, calling a method with a dozen parameters when most of them are null seems like a poor design that would benefit from a rethink.

if (defaultUrl.length() <= API_MAX_URL_LENGTH) {
addEncodedParameter(data, MESSAGE_KEY_URL, defaultUrl);
} else {
logger.error("The url is greater than " + API_MAX_URL_LENGTH + " characters.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use parameterized logging instead of string concatenation.

if (defaultUrlTitle.length() <= API_MAX_URL_TITLE_LENGTH) {
addEncodedParameter(data, MESSAGE_KEY_URL_TITLE, defaultUrlTitle);
} else {
logger.error("The url title is greater than " + API_MAX_URL_TITLE_LENGTH + " characters.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use parameterized logging instead of string concatenation.


if (!StringUtils.isEmpty(apiKey)) {
addEncodedParameter(data, MESSAGE_KEY_API_KEY, apiKey);
} else if (StringUtils.isEmpty(apiKey) && !StringUtils.isEmpty(defaultApiKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(apiKey) && is unneeded and would read better if it were removed.


if (!StringUtils.isEmpty(user)) {
addEncodedParameter(data, MESSAGE_KEY_USER, user);
} else if (StringUtils.isEmpty(user) && !StringUtils.isEmpty(defaultUser)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(user) && is unneeded and would read better if it were removed.


if (!StringUtils.isEmpty(device)) {
addEncodedParameter(data, MESSAGE_KEY_DEVICE, device);
} else if (StringUtils.isEmpty(device) && !StringUtils.isEmpty(defaultDevice)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(device) && is unneeded and would read better if it were removed.


if (!StringUtils.isEmpty(title)) {
addEncodedParameter(data, MESSAGE_KEY_TITLE, title);
} else if (StringUtils.isEmpty(title) && !StringUtils.isEmpty(defaultTitle)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(title) && is unneeded and would read better if it were removed.

logger.error("The url is greater than " + API_MAX_URL_LENGTH + " characters.");
return false;
}
} else if (StringUtils.isEmpty(url) && !StringUtils.isEmpty(defaultUrl)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(url) && is unneeded and would read better if it were removed.

logger.error("The url title is greater than " + API_MAX_URL_TITLE_LENGTH + " characters.");
return false;
}
} else if (StringUtils.isEmpty(urlTitle) && !StringUtils.isEmpty(defaultUrlTitle)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(urlTitle) && is unneeded and would read better if it were removed.


if (!StringUtils.isEmpty(sound)) {
addEncodedParameter(data, MESSAGE_KEY_SOUND, sound);
} else if (StringUtils.isEmpty(sound) && !StringUtils.isEmpty(defaultSound)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part StringUtils.isEmpty(sound) && is unneeded and would read better if it were removed.

@CrackerStealth CrackerStealth force-pushed the bugfix/pushover-default-api-case branch from 76998f7 to 3d78ab1 Compare February 28, 2017 15:36
@CrackerStealth CrackerStealth force-pushed the bugfix/pushover-default-api-case branch from 3d78ab1 to 949fd76 Compare February 28, 2017 15:37
@CrackerStealth
Copy link
Contributor Author

Changes to the code based on review as requested.

Signed-off-by: Chris Graham crackerstealth@gmail.com (github: CrackerStealth)

@9037568 9037568 added this to the 1.10.0 milestone Mar 1, 2017
@9037568 9037568 merged commit 42ed485 into openhab:master Mar 1, 2017
kaikreuzer pushed a commit that referenced this pull request Dec 2, 2017
The changes reflect the this PR:
#5123
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants