Jsmsgr
An easy way to publish transactional messages (SMS, EMAIL, etc.) to Semaphore for their publication!
Requirements
This app requires two other apps to work properly:
- jsm-user-services;
- django-stomp.
Both apps must have been configured properly. Their configs are as follows, including jsmsgr lib:
########################
# Django settings file #
########################
import os
INSTALLED_APPS = [
"...",
"django_stomp",
"jsm_user_services",
"jsmsgr", # add this lib to the INSTALLED_APPS
]
# django-stomp config
STOMP_SERVER_HOST = os.getenv("STOMP_SERVER_HOST")
STOMP_SERVER_PORT = os.getenv("STOMP_SERVER_PORT")
STOMP_SERVER_USER = os.getenv("STOMP_SERVER_USER")
STOMP_SERVER_PASSWORD = os.getenv("STOMP_SERVER_PASSWORD")
STOMP_USE_SSL = os.getenv("STOMP_USE_SSL", "True")
LISTENER_CLIENT_ID = os.getenv("STOMP_CONSUMPTION_QUEUE")
# jsm-user-services config
USER_API_HOST = os.environ.get("USER_API_HOST")
Installing
pip install jsmsgr
Setup
In order to use the lib, add the following env variable which sets the final semaphore destination name:
import os
JSMSGR_DESTINATION=os.getenv("JSMSGR_DESTINATION")
Using the lib
Publishing a single message
from jsmsgr.api import send_msg_to_user
msg_dict = {
"msg": "Hello, there, ###_USER_NAME_###",
"type": "sms",
"external_id": "external123",
"callback_mo_destination": "/queue/mo",
"to_user_id": "a58c4853-2fa5-4891-80c7-f48287dbf403", # user_id to send the msg to
}
send_msg_to_user(msg_dict) # creates a publisher internally
send_msg_to_user(msg_dict, semaphore_publisher=your_publisher) # user your publisher
Publishing a list of messages
from jsmsgr.api import send_msgs_to_user
msgs_dict = {
"msgs": [
{
"msg": "Hello, there, ###_USER_NAME_###",
"type": "sms",
"external_id": "external123",
"callback_mo_destination": "/queue/mo",
"to_user_id": "a58c4853-2fa5-4891-80c7-f48287dbf403", # user_id to send the msg to
},
{
"msg": "<strong>Hello world there, ###_USER_NAME_###</strong>",
"subject": "sub1",
"type": "email",
"to_user_id": "a58c4853-2fa5-4891-80c7-f48287dbf403",
},
{
"msg": "<strong>Hello world there once again, ###_USER_NAME_###</strong>",
"subject": "sub1",
"type": "email",
"to_user_id": "a58c4853-2fa5-4891-80c7-f48287dbf403",
}
]
}
send_msgs_to_user(msgs_dict) # creates a publisher internally
send_msgs_to_user(msgs_dict, semaphore_publisher=your_publisher) # user your publisher
Replacing tags in the original message
Some tags are used to perform string replacements, such as the user name, in the original message. Some tags are the following:
###_USER_NAME_###: Replaced by user name (name of the user with the given to_user_id parameter value).
Example:
"Hello there, ###_USER_NAME### !"
Is sent as:
"Hello there, Igor !"
Metadata
Release files for jsmsgr 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsmsgr-0.0.11.tar.gz | 5.7 kB | Without provenance | Details for jsmsgr-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsmsgr-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for jsmsgr-0.0.11-py3-none-any.whl |
Total release size: 13.8 kB
Release files / jsmsgr-0.0.11.tar.gz
| Download URL | jsmsgr-0.0.11.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca74853721d7591e0a148bdc766df51fbb359c20c72d10441e32cfc08d75921e
|
|
BLAKE2b-256 checksum How to use checksums |
8515976c9f875c7501f02b09714cac6815fe11b2d2b6aa2f20176438f6858f22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|
Release files / jsmsgr-0.0.11-py3-none-any.whl
| Download URL | jsmsgr-0.0.11-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b22ec3cb0f108046ad306bcb2728090821d25f32e3eba9006fe423746218fc58
|
|
BLAKE2b-256 checksum How to use checksums |
1af0bbfe7a27d7e9e3e55887c4f15fae428287e497f0514dd243e5c50493674d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|
Security for jsmsgr 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.