Implement filter signals for message processing
This commit is contained in:
parent
a1505bed44
commit
8a6db379e4
4 changed files with 19 additions and 2 deletions
|
@ -9,6 +9,7 @@ from dbsettings.functions import dbsettings
|
|||
|
||||
from ..signals import send_message
|
||||
from ..models import GatewayUser
|
||||
from ..helpers import run_filters
|
||||
|
||||
class TelegramWebhookView(View):
|
||||
def post(self, *args, **kwargs):
|
||||
|
@ -29,4 +30,6 @@ def telegram_sender(sender, **kwargs):
|
|||
settings = GatewayUser.objects.get(user=notification.recipient, gateway="telegram")
|
||||
chat_id = settings.gatewayusersetting_set.get(key="chat_id").value
|
||||
|
||||
TelegramDispatcher().send(notification.content, chat_id)
|
||||
text = run_filters(notification)
|
||||
|
||||
TelegramDispatcher().send(text, chat_id)
|
|
@ -27,3 +27,4 @@ def send_notifications(sender, **kwargs):
|
|||
pass # TODO: See above
|
||||
|
||||
return returns
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import filtersignals
|
||||
|
||||
from dbsettings.functions import getValue
|
||||
|
||||
make_message = filtersignals.FilterSignal()
|
||||
|
||||
def run_filters(notification):
|
||||
return make_message.send_robust(notification.__class__, recipient=notification.recipient, content=notification.content, app=notification.app)["content"]
|
||||
|
||||
@filtersignals.receiver(make_message, 500)
|
||||
def notification_placeholders(sender, **kwargs):
|
||||
return {"content": kwargs["content"].replace("%KUMIFYURL%", getValue("KUMIFY_URL", "your Kumify instance"))}
|
|
@ -6,6 +6,7 @@ django-multiupload
|
|||
django-storages
|
||||
git+git://github.com/Chive/django-multiupload.git@ba52e161a68ce19062c3655e89544c2d377990a0#egg=multiupload
|
||||
git+https://kumig.it/kumisystems/django-dbsettings.git
|
||||
git+https://kumig.it/kumisystems/django-filtersignals.git
|
||||
mysqlclient
|
||||
boto3
|
||||
argon2_cffi
|
||||
|
|
Loading…
Reference in a new issue