Skip to content
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

Added Synology Chat support #944

Merged
merged 3 commits into from
Nov 19, 2023
Merged

Added Synology Chat support #944

merged 3 commits into from
Nov 19, 2023

Conversation

caronc
Copy link
Owner

@caronc caronc commented Sep 9, 2023

Description:

Related issue (if applicable): #908

Added Synology Chat Support

Syntax

Valid syntax is as follows:

  • synology://{hostname}}/{token}
  • synology://{hostname}:{port}/{token}
  • synology://{user}:{password}@{hostname}/{token}
  • synology://{user}:{password}@{hostname}:{port}/{token}

The secure versions (https):

  • synologys://{hostname}/{token}
  • synologys://{hostname}:{port}/{token}
  • synologys://{user}:{password}@{hostname}/{token}
  • synologys://{user}:{password}@{hostname}:{port}/{token}

Parameter Breakdown

Variable Required Description
hostname Yes The Web Server's hostname
token Yes The Synology Chat Incoming Token generated
port No The port our Web server is listening on. By default the port is 80 for synology:// and 443 for all synologys:// references.
user No If you're system is set up to use HTTP-AUTH, you can provide username for authentication to it.
password No If you're system is set up to use HTTP-AUTH, you can provide password for authentication to it.
file_url No Synology allows you to directly link to a URL containing an attachment. If you set this on the Apprise URL, it will be passed down to the synology request made under the hood.

Example

Send a Synology Chat notification to our web server listening on port 80:

# Assuming our {hostname} is synology.server.local
# Assuming our {token} is abc123
apprise synology://synology.server.local/abc123

New Service Completion Status

  • apprise/plugins/NotifySynology.py
  • KEYWORDS
    • add new service into this file (alphabetically).
  • README.md
    • add entry for new service to table (as a quick reference)
  • packaging/redhat/python-apprise.spec
    • add new service into the %global common_description

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@908-synology-chat-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  "synology://myserver.hotname/mytoken"

@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f1d697f) 99.51% compared to head (70b976a) 99.51%.
Report is 3 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #944    +/-   ##
========================================
  Coverage   99.51%   99.51%            
========================================
  Files         125      126     +1     
  Lines       16760    16868   +108     
  Branches     3434     3457    +23     
========================================
+ Hits        16679    16787   +108     
  Misses         70       70            
  Partials       11       11            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caronc
Copy link
Owner Author

caronc commented Sep 17, 2023

Reached out to Synology Comunity for testing support

@hhhguany
Copy link

hhhguany commented Nov 14, 2023

Hi,

I have conducted tests on my own Synology NAS and successfully sent them out via apprise. However, no messages were received on Synology Chat. Here are the verbose logs generated by apprise:

apprise -t "Test Title" -b "Test Message" "synologys://nas.domain:8888/token” -vvvv
2023-11-14 18:05:47,624 - DEBUG - Could not load translation path: /home/user/apprise/lib/python3.10/site-packages/apprise/i18n/en
2023-11-14 18:05:47,627 - TRACE - Synology Chat URL synologys://nas.domain:8888/token unpacked as:
user="None"
password="None"
port=“8888”
host="nas.domain"
fullpath=""
path="/"
query="token"
schema="synologys"
url="synologys://nas.domain:8888/token"
qsd="{}"
qsd+="{}"
qsd-="{}"
qsd:="{}"
secure="True"
verify="True"
headers="{}"
token="token"
2023-11-14 18:05:47,627 - DEBUG - Loaded Synology Chat URL: synologys://nas.domain:8888/x...x/?format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes
2023-11-14 18:05:47,627 - DEBUG - Synology Chat POST URL: https://nas.domain:8888/webapi/entry.cgi (cert_verify=True)
2023-11-14 18:05:47,627 - DEBUG - Synology Chat Payload: {'text': 'Test Title\r\nTest Message'}
2023-11-14 18:05:47,758 - INFO - Sent Synology Chat notification.

Since Synology Chat does not provide any interface, I’m currently unable to ascertain the root cause of the issue. However, I can confirm that there is no issue with the network link between my test machine and Synology Chat.

Thank you for your work. If you currently don’t have Synology Chat, please inform me when the next version is released, and I would be more than willing to assist you in testing it.

@caronc
Copy link
Owner Author

caronc commented Nov 16, 2023

What happens if you just use synology:// and not synologys://

I'm confused because in your example you have ssl_verify set to true (default value if not over-ridden), and you're connecting to nas.domain:8888 which i would presume wouldn't have a CA Authority to verify against (or does it?).

Is your nas.domain:8888 listening on an SSL connection?

The fact it is sending okay though without an issue has me confused, i'll need to see if i can figure out why it doesn't work. I don't have Synology device unfortunately, so i am relying on kind people like you to test; thanks again for doing this!

@caronc caronc force-pushed the 908-synology-chat-support branch from 22ee448 to b0678dd Compare November 16, 2023 03:20
@hhhguany
Copy link

My NAS is correctly configured with an SSL certificate on port 8888, and I have also tried the synology://, unfortunately it does not work.

@hhhguany
Copy link

hhhguany commented Nov 16, 2023

I suspect the problem is in the payload, but I'm not too familiar with the apprise code, so I have not been able to figure out exactly where is the bug is. I found some projects on github written in python, that might give you some help.

@hhhguany
Copy link

In synochat, the payload is like this. Start with a repeat payload=. I believe this is the reason for the bug.

# Data dictionary to be sent to the server
payload_data = {'text': text}

# Check if there is a URL to include in the request
if file_url:
	payload_data['file_url'] = file_url

# Prepare the payload
payload = f"payload={json.dumps(payload_data)}"

@caronc
Copy link
Owner Author

caronc commented Nov 18, 2023

Thank you @hhhguany for all our great effort, support and the links you shared. I followed your advice; i'm looking forward to hearing back from you how it went! 🚀

@hhhguany
Copy link

It's working fine!Thanks for your work.

@caronc caronc merged commit a25ff00 into master Nov 19, 2023
12 checks passed
@caronc caronc deleted the 908-synology-chat-support branch December 29, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants