caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
12.08k stars 422 forks source link

Request for support for Signal #223

Closed TheFiZi closed 2 years ago

TheFiZi commented 4 years ago

:loudspeaker: What is the name of the service? Signal

:link: Provide some details about the service that can help with it's development.

:bulb: Anything else? I found some other projects that appear to be able to do this:

amotl commented 4 years ago

Hi Eric,

thanks for suggesting that. Chris, you might like to add [1,2] to your list of baseline implementations you want to put some research into.

With kind regards, Andreas.

[1] https://github.com/Syndace/python-omemo [2] https://github.com/Syndace/python-omemo-backend-signal

caronc commented 4 years ago

Applicable reference: Basically it's a closed ticket for nzb-notify (which in turn just uses Apprise). At the time the research deemed the keys needed to negotiate a connection with the signal server would be really, really long (hence so would the Apprise URL).

Not sure if I went in the wrong direction here with my research, but is that reference still applicable to this request?

TheFiZi commented 4 years ago

Potentially good news that could make this more flexible: https://www.zdnet.com/article/signal-to-move-away-from-phone-numbers-as-user-ids/

caronc commented 4 years ago

Hi guys,

Sorry i haven't touched this; it's a bit overwhelming! There is a lot of overhead. What is everyone currently using as their existing solution? It seems like if everyone installed a SignalD instance, the overhead involved in handling all of the encryption problems significantly shrinks.

But the second part of this problem is that Signal requires you to register your phone # and input a verification code. I'm curious how you want this to work with Apprise? This type of plugin requires quite a bit of 2 way handshaking up front. Then it looks like once you're set up, it's api is as easy as any other (with respect to SignalD).

What was everyone's mindset around this type of wrapper?

Chris

TheFiZi commented 4 years ago

I believe I got SignalD working but it took over my Signal account from my phone, which makes sense since I re-used my only phone number to get it working.

Hopefully they are still working on getting Signal working with out phone numbers which will likely make this a lot more practical.

A friend suggested signing up for a burner number but that's even more overhead.

poVoq commented 3 years ago

This might give some hints on how to best talk with Signald in Python: https://github.com/tulir/mautrix-signal

vrillusions commented 2 years ago

What I currently use (there's support for it in home assistant which is where I found it) https://github.com/bbernhard/signal-cli-rest-api

It's a docker container and does a basic JSON api. Downside is setup is a bit complicated. But once you have that having new things send notifications is pretty simple. They list a bunch of examples but here's an example:

curl -X POST -H "Content-Type: application/json" \
    -d '{"message": "$MSG_TITLE - $MSG_BODY", "number": "$SENDER", "recipients": ["$RECIPIENT"]}' \
    'http://$SERVER/v2/send'

Note that $RECIPIENT and $SENDER are the relevant phone numbers with country code. For example +12225551234.

HeyVern commented 2 years ago

^^Bump Home: https://github.com/bbernhard/signal-cli-rest-api API: https://bbernhard.github.io/signal-cli-rest-api/ This would be SO VERY useful. It's working well with other things like HA.

I tried using json:// but had issues. Seems like this would be "low hanging fruit" to implement and a real win! Go with the REST version as it is a single docker container that can serve multiple services.

caronc commented 2 years ago

Instructions are in PR to test; i think it's a good first stab at your request anyhow. I'm hoping someone can test it out for me and let me know.

the next step would be to add attachment support as i see that the API supports this. Wouldn't be too difficult to add the --attachment (-a) support for this.

HeyVern commented 2 years ago

@caronc You rock sir!! I'll try and get a test going soon.

HeyVern commented 2 years ago

@caronc I keep getting unparsable URL errors. I've tried apprise signal://10.0.0.112:8080/+12512222222/+12513333333 as well as apprise signal://10.0.0.112:8080/12512222222/12513333333 -V reports v.0.9.7

caronc commented 2 years ago

@HeyVern ; see comment here

caronc commented 2 years ago

Code is in the current release if you want to try again.

HeyVern commented 2 years ago

Sweet. Thanks!! And again, if no one has told you today. . . you rock!!

HeyVern commented 2 years ago

@caronc Here is what I get when running on latest

>apprise signal://10.0.0.112:8080/+1251111111/+12512222222

/usr/local/apprise/utils.py:704: FutureWarning: Possible nested set at position 12 pmatch = re.search(

>apprise -V

Apprise v0.9.8.1

caronc commented 2 years ago

Hmm, okay. I'm basing this off of the wget call in @vrillusions's post.

I'll dig a little deeper; perhaps he can have a look and maybe spot what is off?

caronc commented 2 years ago

I fixed the future warning issue now in the latest release. I'll hopefully have a chance to look into this more this weekend

caronc commented 2 years ago

@HeyVern, i can't seem to reproduce your issue. I've gone through the Signal API code with a fine tooth comb and simply can't see the issue you're identifying.

I'm performing the Server POST to a T as defined here.

On that same note, since i spent so much time in this area of the code, I added Attachment and Signal Group support.

Perhaps you can see what is going on? Or maybe someone else in this chat could give it a go?

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in
# This way you can just destroy it after when it's all over.
# The below will create a directory called apprise
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@223-signal-enhancements

# Be sure you're running your Signal API Server and query it like so
apprise -b "Test Message" signal://server:port/from_no/to_no

# You can also attach files now too:
apprise -b "Test Message" --attach=/path/to/image.png \
    signal://server:port/from_no/to_no

# Group support added too:
# The following syntax is valid:
#  - @name (translates to `group.name` before post
#  - group.name (no change made)
#  - @group.name (also acceptable, the @ is dropped before post)
apprise -b "Test Message" signal://server:port/from_no/@name1/group.name3/@group.name2

# you can mix and match group's and phone numbers in the Apprise URL
HeyVern commented 2 years ago

@caronc Thanks for the work as always. I'll try again.

I may even run apprise with the stand alone docker container from Docker Hub to rule anything else on my side that could be causing an issue. Has that been updated to latest?

caronc commented 2 years ago

The code is only in the branch as defined above. But i too will start setting up a signal account as well if this doesn't work.

The plugin assumes you've registered your phone number with signal via the API. If it doesn't work, another thing you can try is adding -vvv to the Apprise command. Maybe it will shed more details as to why it's not working

caronc commented 2 years ago

I significantly updated the documentation on the wiki page. I set myself up a signal account and even included screenshots of my success (full attachment support built in).

All instructions on how to link the device is in place.

I'll close this ticket off since it works for me

HeyVern commented 2 years ago

Fantastic!! Thank you. Excellent work!! Having signal support is going to be such a plus. Much appreciate all the hard work!!