Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ninjascl/airnotifier-moodle-bridge
A replacement API for AirNotifier Moodle Plugin that connects directly to Firebase and other Push Notification Providers
https://github.com/ninjascl/airnotifier-moodle-bridge
airnotifier api fastify firebase javascript moodle nodejs plugin pusher
Last synced: about 5 hours ago
JSON representation
A replacement API for AirNotifier Moodle Plugin that connects directly to Firebase and other Push Notification Providers
- Host: GitHub
- URL: https://github.com/ninjascl/airnotifier-moodle-bridge
- Owner: NinjasCL
- License: mit
- Created: 2020-04-22T05:01:11.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-01T22:14:40.000Z (almost 2 years ago)
- Last Synced: 2023-03-06T23:50:59.376Z (over 1 year ago)
- Topics: airnotifier, api, fastify, firebase, javascript, moodle, nodejs, plugin, pusher
- Language: JavaScript
- Homepage: https://ninjas.cl
- Size: 636 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
# AirNotifier Moodle Plugin Bridge
A replacement API for https://github.com/airnotifier/airnotifier/[AirNotifier] server for the _AirNotifier Moodle Plugin_ that connects directly to _Firebase_, or others _Push Notification Providers_. This was made since newer versions of _AirNotifier_ seems to be not working with the _Moodle Plugin_ due to usage of old apis. This server implements all needed endpoints and acts as a middleware between _Moodle AirNotifier Plugin_ and _Push Notification Providers_.
## Installation
This server uses https://nodejs.org/en/[_NodeJS_] instead of _Python_ (Used by _AirNotifier_). Be sure to have _NodeJS_ version >= 10 installed.
- `$ git clone https://github.com/NinjasCL/airnotifier-moodle-bridge`.
- `$ cd airnotifier-moodle-bridge`.
- `$ npm install`.
- `$ npm install -g forever`.Also install https://firebase.google.com/docs/libraries[Firebase SDK] to your platform in order to obtain _FCM Token_ or the other Client SDKs needed.
## Configure
You would need to get the configuration from your https://console.firebase.google.com[firebase console] or other adapters.
Check the `index.js` file for each adapter configuration.Also the headers `X-An-App-Key` and `X-An-App-Name` should be set in both server config and moodle plugin settings. Is recommended a random value using `npm run uuid` script for `X-An-App-Key`.
Be sure to set the correct server address and port in your _Moodle Plugin Settings_. (Beware of trailing slashes in the server address).
Check that you can interact with the server. The root endpoint should return a json with the version number.
## Usage
- Start the server with `npm start`.
- Send `FCM Token`. Not the native token.- You can also use `npm run forever` to init a background process.
```sh
#!/bin/sh
forever start --minUptime 1000 --spinSleepTime 1000 -o out.log -e err.log index.js
```### Example token registration
This is how you can send from your _Firebase SDK_ instance to your _Moodle_ server.
You have to send the _FCM Token_ in the _pushid_ param.Note: Contains Invalid token values for security purposes.
```
https://my.moodle.site/webservice/rest/server.php?wstoken=skkd1m1m3123km32kkckas3&appid=com.myapp.seed&name=Ninja's%20iPhone&model=iPhone&platform=ios&version=10.3.2&pushid=dWZfI--pSUXygaBKRVAslm:APA91bE-GiFkSCg-r1z-XoOVm-cPoXLd9dbhs3bZjPJb2t8GCCVFzrBE8UmoJSsjGbN2MhRq1MllOfFB_kOlZ1_3jvHaSrqrn7plxH1&uuid=12311-8EC8-4A93-A6C231228&wsfunction=core_user_add_user_device&moodlewsrestformat=json
```### Example notification
You can configure this request in _Postman_ or similar HTTP client.
#### Endpoint
- POST: `http://:3000/api/v2/push`
#### Headers
- X-AN-APP-KEY: `A1159649-4DE0-4449-A8CF-ED0922312BF2`
- X-AN-APP-NAME: `myapp`#### Body
- format: `x-www-form-urlencoded`
- token: ``
- extra[smallmessage]: `An small excerpt of the message`
- extra[sitefullname]: `Who is sending the message`
- extra[contexturl]: `Where to send the user after notification click`## Sponsor https://www.fus-ed.com/[Fused]
This code was made possible thanks to the folks at https://www.fus-ed.com/[Fused].
_Fused_ merges decades of performance experience with leading-edge technology.## Made by https://ninjas.cl[Ninjas.cl]
This was developed (with :love:) by https://ninjas.cl[Ninjas.cl].
## LICENSE
MIT