Code Monkey home page Code Monkey logo

pushover-to-xmpp's Introduction

Pushover to XMPP

This repository contains a <500 LOC Pushover to XMPP bridge that uses Pushover's Open Client API to get notified about new Pushover notifications and forwards them to an XMPP account, using go-xmpp.

Background

The reason for building this was my switch over from /e/OS to GrapheneOS (read more about that here) and hence the lack of a Pushover client that would function without GSF/GCM/FCM. Unfortunately the official Pushover Android app depends on the Google Service Framework and implements no websocket-driven fallback on its own. Hence, on Graphene it refuses to start.

Since I was already using Conversations, an XMPP client that works without GSF/GCM/FCM, the easiest solution for continuing to retrieve Pushover notifications on Android was to simply forward them to my XMPP server.

This quick and (very) dirty Go service does exactly that.

Build

go build .

The binary is named pushover-to-xmpp.

Configure

For the sake of simplicity I added a login.sh script, which basically does what the Pushover API documentation tells under User Login and Device Registration in an automated fashion. The script depends on curl and jq to be available. You can run it as following:

./login.sh <pushover e-mail> <pushover password> <two factor code>

The script does not implement login without 2FA, because you should use 2FA.

The script will output a Device ID and a secret. Keep those.

If you don't trust the script, just perform the curl requests mentioned in the documentation yourself. You don't have to do this before every start, it's only required once or in case you delete the device or the secret is invalidated.

Run

The bridge requires a dedicated XMPP account, either on your own server or a different one that is permitted to S2S with yours. You also have to make sure upfront that the account is able to communicate with the target account. pushover-to-xmpp won't send or accept presence requests on its own, so make sure to pre-configure the account the way you'd need it.

You can run the bridge by exporting its required ENV variables and running the pushover-to-xmpp binary:

export PTX_DEVICE_ID='<pushover device id>' \
       PTX_SECRET='<pushover secret>' \
       PTX_XMPP_SERVER='your-xmpp.org:5222' \
       PTX_XMPP_USER='[email protected]' \ 
       PTX_XMPP_PASSWORD='password' \
       PTX_XMPP_TLS=true \
       PTX_XMPP_TARGET='[email protected]'

The PTX_XMPP_TARGET is the target user that the bridge should forward Pushover notifications to.

It's best to run the bridge via e.g. supervisord, in order to make sure it keeps running and, in case it won't, you're being notified about that.

For that purpose create a dedicated user (e.g. ptx), download and unpack one of the binary releases and add something along these lines to your /etc/supervisord.conf (or /usr/local/etc/supervisord.conf):

[program:pushover-to-xmpp]
command=/home/ptx/pushover-to-xmpp
numprocs=1
autostart=true
startsecs=5
startretries=3
autorestart=true
user=ptx
directory=/home/ptx
environment=PTX_DEVICE_ID="...",PTX_SECRET="...",PTX_XMPP_SERVER="...",...

(environment should contain the same ENVs as listed above, separated by comma, with each key's value in quotes)

Whenever the bridge starts, the target user will receive a "Hello World" message to know that the bridge was just (re-?)started.

pushover-to-xmpp's People

Contributors

dependabot[bot] avatar mrusme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.