Ejemplo n.º 1
0
def send_notification(person_id, subject, messages):
    """
    Send email notification to given person. Use the job queue if it is
    activated.
    """
    person = persons_service.get_person(person_id)
    email_message = messages["email_message"]
    slack_message = messages["slack_message"]
    if person["notifications_enabled"]:
        if config.ENABLE_JOB_QUEUE:
            queue_store.job_queue.enqueue(
                emails.send_email,
                args=(
                    subject,
                    email_message + get_signature(),
                    person["email"],
                ),
            )
        else:
            emails.send_email(subject, email_message + get_signature(),
                              person["email"])

    if person["notifications_slack_enabled"]:
        organisation = persons_service.get_organisation()
        userid = person["notifications_slack_userid"]
        token = organisation.get("chat_token_slack", "")
        if config.ENABLE_JOB_QUEUE:
            queue_store.job_queue.enqueue(chats.send_to_slack,
                                          args=(token, userid, slack_message))
        else:
            chats.send_to_slack(token, userid, slack_message)

    return True
Ejemplo n.º 2
0
def invite_person(person_id):
    """
    Send an invitation email to given person (a mail telling him/her how to
    connect on Kitsu).
    """
    organisation = get_organisation()
    person = get_person_raw(person_id)
    subject = "You are invited by %s to join their Kitsu production tracker" % (
        organisation["name"])
    body = """Hello %s,

Your are invited by %s to collaborate on their Kitsu production tracker.
You can connect here to start using it:

https://%s

Your login is: %s
Your password is: default

You will be invited to modify your password on first connection.

Thank you and see you soon on Kitsu,

%s Team
""" % (person.first_name, organisation["name"], config.DOMAIN_NAME,
       person.email, organisation["name"])
    emails.send_email(subject, body, person.email)
Ejemplo n.º 3
0
def send_notification(person_id, subject, message):
    """
    Send email notification to given person. Use the job queue if it is
    activated.
    """
    person = persons_service.get_person_raw(person_id)
    if person.notifications_enabled:
        if config.ENABLE_JOB_QUEUE:
            queue_store.job_queue.enqueue(
                emails.send_email,
                args=(subject, message, person.email)
            )
        else:
            emails.send_email(subject, message, person.email)
    return True
Ejemplo n.º 4
0
def send_email_task(subject, message, email):
    emails.send_email(subject, message, email)