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

[Enhancement] Send alert to push notification aggregator service #140

Open
SingingDwarf opened this issue Feb 9, 2022 · 6 comments
Open

Comments

@SingingDwarf
Copy link

Suggestion for enhancement - send notifications to a self hosted push aggregator service, such as Apprise (https://github.com/caronc/apprise) which would allow users to send notifications to services of their choice, but with only a single integration point for this project to maintain.

@kx1t
Copy link
Member

kx1t commented Feb 9, 2022

hey @SingingDwarf , thanks for the suggestion.
In reality, we are working on changing the notification architecture for Planefence. PF and PA will call into a separate container that would do notifications.

At first sight, apprise may be interesting to use as the underlying notification engine, although I'd need to think a bit on the best way for the end user to switch notification methods on/off, and to provide the credentials needed for this.

As a MVP, we'd be looking to implement Twitter and Discord notifications. People have asked for MQTT as well, and it'd be interesting to enable some of the other ones.

Feel free to join a bunch of us at the #planefence channel on this Discord server where we discuss these things: https://discord.gg/VDT25xNZzV

@kx1t
Copy link
Member

kx1t commented Feb 12, 2022

@SingingDwarf I have been playing with apprise, and it was easy to figure out how to send tweets.
However, I'm struggling to find out how to upload images to be used with the tweet.

Currently, using twurl, you first upload the image and you get a json object that contains an Image ID that you subsequently reference in your tweet:

# upload the image and get a Media ID:
TW_MEDIA_ID=$(twurl -X POST -H upload.twitter.com "/1.1/media/upload.json" -f /tmp/snapshot.png -F media | sed -n 's/.*\"media_id\":\([0-9]*\).*/\1/p')
# Send a tweet and reference the Media ID to be used
LINK=$(echo `twurl -r "status=$TWEET&media_ids=$TW_MEDIA_ID" /1.1/statuses/update.json` | tee -a /tmp/tweets.log | jq '.entities."urls" | .[] | .url' | tr -d '\"')
# LINK now contains the URL of the tweet

I successfully sent a tweet with apprise like this:

apprise -b "#PlaneAlert ...insert body text here" twitter://$TWITTER_CONSKEY/$TWITTER_CONSSECRET/$TWITTER_ACCTOKEN/$TWITTER_ACCSECRET/?mode=tweet

I tried adding the media ID in the same request, didn't work. I tried to send the file attachment without body, and apprise complained of not having any text in the body:

apprise -a file:///run/notifier/screenshot/screenshot.png -b "#PlaneAlert ...insert body text here" twitter://$TWITTER_CONSKEY/$TWITTER_CONSSECRET/$TWITTER_ACCTOKEN/$TWITTER_ACCSECRET/?mode=tweet 

apprise -a file:///run/notifier/screenshot/screenshot.png twitter://$TWITTER_CONSKEY/$TWITTER_CONSSECRET/$TWITTER_ACCTOKEN/$TWITTER_ACCSECRET/?mode=tweet 

Do you have any idea how to get this done, or who I can ask?

@kx1t
Copy link
Member

kx1t commented Mar 11, 2022

As a follow-up, I have been making progress implementing a separate notification-container that will use apprise. The author of that package has been very helpful making some minor additions to the package that, among other things, will show the result object from sending tweets, etc.

Progress is slow but forthcoming.

@SingingDwarf
Copy link
Author

SingingDwarf commented Jun 10, 2022

@kx1t Sorry for the radio silence on this, unfortunately 'life' has been in the way recently.

Is the work you refer to above using the NOTIFICATION_SERVER setting in the config file? I cannot find any documentation relating to this setting, so assume that it is new/undocumented feature currently?

Did you still require help on sending the attachement? It's a while since I looked into Apprise, but can take another look if it would be helpeful.

@kimfr
Copy link

kimfr commented Oct 26, 2023

@kx1t - is there any update on using Apprise? I'm looking to implement Telegram - currently using it in some scripts - rather easy as you just issue a curl command with token,api and message.

I would like plane-alert to send me a Telegram message whenever a new plane from the alert file is registered.

@beercity
Copy link

adding Ntfy (ntfy.sh) as an option would be great as well.

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

No branches or pull requests

4 participants