matt0550/rapisardi_notifications
API per ricevere le sostituzioni dell'Istituto Rapisardi da Vinci. Le sostituzioni vengono anche inviate tramite email ad ogni nuovo aggiornamento.
API to receive the substitutions of the Rapisardi da Vinci Institute. The substitutions are also sent via email with each new update.
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with the Istituto Rapisardi da Vinci, or any of its subsidiaries or its affiliates.
docker compose build
- Build the container with docker compose build
docker compose up -d
- Start the container with docker compose up -d
http://<ip>:8080
- Open the browser at http://<ip>:8080
pip install -r requirements.txt
- Install the dependencies with pip install -r requirements.txt
uvicorn api:app --reload
- Start the server with uvicorn api:app --reload
Nome - Name | Descrizione - Description | Default | Obbligatorio - Mandatory |
---|---|---|---|
SMTP_HOST | Host SMTP per l'invio delle email - SMTP host for email sending | None | :heavy_check_mark: |
SMTP_PORT | Porta SMTP per l'invio delle email - SMTP port for email sending | 587 | :heavy_check_mark: |
SMTP_USERNAME | Username SMTP per l'invio delle email - SMTP username for email sending | None | :heavy_check_mark: |
SMTP_PASSWORD | Password SMTP per l'invio delle email - SMTP password for email sending | None | :heavy_check_mark: |
SMTP_SSL | Abilita SSL per l'invio delle email - Enable SSL for email sending | True | :heavy_check_mark: |
SMTP_FROM | Indirizzo email mittente - Sender email address | None | :heavy_check_mark: |
MONGODB_HOST | Host MongoDB - MongoDB host | None | :heavy_check_mark: |
MONGODB_USERNAME | Username MongoDB - MongoDB username | None | :heavy_check_mark: |
MONGODB_PASSWORD | Password MongoDB - MongoDB password | None | :heavy_check_mark: |
MONGODB_DATABASE | Database MongoDB - MongoDB database | None | :heavy_check_mark: |
ADMIN_TOKEN | Token per l'aggiornamento del database - Token for database update | None | :heavy_check_mark: |
Il token per l'aggiornamento del database può essere generato con il comando python -c "import secrets; print(secrets.token_urlsafe())"
.
The token for database update can be generated with the command python -c "import secrets; print(secrets.token_urlsafe())"
.
ImportantIl token generato non deve contenere caratteri non supportati da JSON.The generated token must not contain characters not supported by JSON.
Le API Docs sono disponibili all'indirizzo http://<ip>:8080/docs
.
The API Docs are available at http://<ip>:8080/docs
.
Esempio di database - Example of database:
Users collection:
{
"_id": {
"$oid": ""
},
"email": "@gmail.com",
"classi": [
"5C inf"
],
"endpoint": "margherita",
"last_sostituzioni": {
"5C inf": [
"",
"",
"",
"",
"",
"",
""
]
},
"last_notification": {
"5C inf": {
"$date": "2023-12-18T00:00:23.630Z"
}
}
}
Per attivare le notifiche per un singolo utente, aggiungere alla collection users
un documento con tutti i campi sopra elencati.
To activate notifications for a single user, add to the users
collection a document with all the fields listed above.
Le notifiche vengono inviate tramite email all'indirizzo specificato nel campo email
del documento nella collection users
.
Tramite un cronjob bisogna inviare una richiesta POST all'endpoint /admin/update_db
passandogli il token specificato nel campo ADMIN_TOKEN
delle variabili d'ambiente come parametro token
(Form). Nella mia configurazione, il cronjob viene eseguito ogni ora.
Notifications are sent via email to the address specified in the email
field of the document in the users
collection.
Through a cronjob you have to send a POST request to the /admin/update_db
endpoint passing the token specified in the ADMIN_TOKEN
field of the environment variables as the token
parameter (Form). In my configuration, the cronjob is executed every hour.
La dashboard è disponibile all'indirizzo http://<ip>:8080/dashboard
.
Tramite la dashboard è possibile da parte dell'utente aggiungere o rimuovere le classi per le quali ricevere le notifiche.
The dashboard is available at http://<ip>:8080/dashboard
.
Through the dashboard the user can add or remove the classes for which to receive notifications.
Le pull request sono benvenute. Per modifiche importanti, aprire prima un issue per discutere di cosa si vuole cambiare.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
docker pull matt0550/rapisardi_notifications