Implement filter signals for message processing
This commit is contained in:
parent
eff769c625
commit
1f78158637
4 changed files with 19 additions and 2 deletions
|
@ -9,6 +9,7 @@ from dbsettings.functions import dbsettings
|
||||||
|
|
||||||
from ..signals import send_message
|
from ..signals import send_message
|
||||||
from ..models import GatewayUser
|
from ..models import GatewayUser
|
||||||
|
from ..helpers import run_filters
|
||||||
|
|
||||||
class TelegramWebhookView(View):
|
class TelegramWebhookView(View):
|
||||||
def post(self, *args, **kwargs):
|
def post(self, *args, **kwargs):
|
||||||
|
@ -29,4 +30,6 @@ def telegram_sender(sender, **kwargs):
|
||||||
settings = GatewayUser.objects.get(user=notification.recipient, gateway="telegram")
|
settings = GatewayUser.objects.get(user=notification.recipient, gateway="telegram")
|
||||||
chat_id = settings.gatewayusersetting_set.get(key="chat_id").value
|
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
|
pass # TODO: See above
|
||||||
|
|
||||||
return returns
|
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
|
django-storages
|
||||||
git+git://github.com/Chive/django-multiupload.git@ba52e161a68ce19062c3655e89544c2d377990a0#egg=multiupload
|
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-dbsettings.git
|
||||||
|
git+https://kumig.it/kumisystems/django-filtersignals.git
|
||||||
mysqlclient
|
mysqlclient
|
||||||
boto3
|
boto3
|
||||||
argon2_cffi
|
argon2_cffi
|
||||||
|
|
Loading…
Reference in a new issue