Skip to content

UnknownTriggerException() in get_template() #14

@anandramani98

Description

@anandramani98

from transmissions import message

gives an import error.

Should it be from transmissions.trigger import message

When i do this i get more exceptions like UnknownTriggerException() in get_template.

Here are the code snippets: (Am trying to implement my own channel here)

from django.conf import settings
from messaging.html_gen_methods import HtmlGen
from transmissions.trigger import message
from transmissions.models import TriggerBehavior

class BaseEmail(object):

def __init__(self, notification):
    self.target_user = notification.target_user
    self.sender = notification.trigger_user
    self.trigger = notification.trigger_name
    self.client = HtmlGen(self.sender, self.trigger)

def check_validity(self):
    raise NotImplementedError()


def send(self):
    try:
        res = self.client.run(to=self.to)
        if not res:
            raise ChannelSendException()
        return res
    except Exception as e:
        raise ChannelSendException("There was an error in sending sms to {}, error: {}".format(self.to, e.args))

@message('welcome-app-user', behavior=TriggerBehavior.TRIGGER_ONCE_PER_CONTENT)
class WelcomeAppUser(BaseEmail):
def check_validity(self):
try:
self.to = self.target_user.email
return True
except:
return False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions