-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[pushover] Added HTML and Monospace formatting option #5846
Conversation
Addedd HTML and Monospace formatting option (https://pushover.net/api#html) Signed-off-by: Jonas Brüstel <jonas.bruestel@piobyte.de>
cweitkamp
left a comment
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.
Thank you very much for this improvement. I have left a comment. And I will test it in the next couple of days.
| } | ||
|
|
||
| if (htmlFormatting) { | ||
| parts.add(new StringPart(MESSAGE_KEY_HTML, MESSAGE_VALUE_HTML, UTF_8_ENCODING)); |
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.
Please use StandardCharsets.UTF_8.name(). Would you be so kind to replace it everywhere in this file?
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.
changed it
|
I maybe see an issue raising. Currently we check for the length of the message plus the title and suppress to send something when the length exceeds 512 characters. Line 362 in 9f1ee25
This will happen very quickly when one will start using HTML in his messages. IIRC the used thresholds are not correct anymore. According to https://pushover.net/api#limits we can increase them to 1024 chars for the message and 250 chars for the title. |
Signed-off-by: Jonas Brüstel <jonas.bruestel@piobyte.de>
|
CI crashed. How can I trigger a new build? |
|
Thanks for the changes.
You can close the PR and reopen it 😉. |
| private static final String JSON_API_URL = "https://api.pushover.net/1/messages.json"; | ||
| private static final String JSON_CANCEL_API_URL = "https://api.pushover.net/1/receipts/{receipt}/cancel.json"; | ||
| private static final String UTF_8_ENCODING = "UTF-8"; | ||
| private static final String UTF_8_ENCODING = StandardCharsets.UTF_8.name(); |
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.
That is okay but not the idea behind my comment. I maybe could have explained it a little bit more in detail.
I think we do not need this constant here. Rather replace it everywhere in this file. One benefit will be that it will be possible to replace it completely in the IOUtils.toString() methods by using the Charset itself to omit UnsupportedCharsetException (or UnsupportedEncodingException, see commons.io API).
Line 510 in b4b7a29
| response = IOUtils.toString(httpPost.getResponseBodyAsStream(), UTF_8_ENCODING); |
Line 605 in b4b7a29
| response = IOUtils.toString(httpPost.getResponseBodyAsStream(), UTF_8_ENCODING); |
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.
Now I understand what you meant.
Unfortunately, this method isn't available in the current commons.io API version.
The method toString(InputStream, String) in the type IOUtils is not applicable for the arguments (InputStream, Charset)
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 see. We are using 2.2 and the expected method is available from 2.3. What a pity.
Signed-off-by: Jonas Brüstel <jonas.bruestel@piobyte.de>
...org.openhab.action.pushover/src/main/java/org/openhab/action/pushover/internal/Pushover.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jonas Brüstel <jonas.bruestel@piobyte.de>
cweitkamp
left a comment
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.
LGTM. Thanks.
|
Hi, |
I really don't know. I've added the addon as jar file in my installation (2.4). I can send you the jar or you can compile it yourself. |
Signed-off-by: Jonas Brüstel jonas@bruestel.net (github: bruestel)