{% extends 'emails/base.html.twig' %} {% block subject %} {%- autoescape false -%} Your daily digest for {{ 'now'|date(user.dateFormat) }}! {%- endautoescape -%} {% endblock %} {% block body_text %} {% autoescape false %} Here's what happened on Ledger today! {% for notification in notifications %} - {{ _self.disaply(user, notification, false)|spaceless }} {% endfor %} Thanks, Your friends at Ledger {% endautoescape %} {% endblock %} {% block body_html_content %}

Here's what happened on Ledger today!

{% for notification in notifications %} {{ _self.disaply(user, notification)|raw }} {% endfor %}

Go to Ledger

{% endblock %} {% macro formatValue(value) %} {{ value is iterable ? value.name ?: 'N/A' : value is same as(true) ? 'True' : value is same as(false) ? 'False' : value ?: 'N/A' }} {% endmacro %} {% macro formatArrayItem(item, index, arrayLength) %} {{ _self.formatValue(item) }} {% if index < arrayLength - 2 %}, {% endif %} {% if index == arrayLength - 2 and arrayLength > 1 %} and {% endif %} {% endmacro %} {% macro disaply(user, notification, html = true) %} {% import 'emails/macros.html.twig' as EUI %} {% set actor = 'You' %} {% set icon = null %} {% set message = null %} {% set body = [] %} {% set redirectTo = null %} {% if notification.type == constant('App\\DBAL\\Types\\NotificationType::WORKSPACE') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.workspace.id}) %} {% elseif notification.type == constant('App\\DBAL\\Types\\NotificationType::STREAM') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.stream.workspace.id ~ '/s/' ~ notification.stream.id}) %} {% elseif notification.type == constant('App\\DBAL\\Types\\NotificationType::MESSAGE') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.stream.workspace.id ~ '/messages/' ~ notification.stream.id}) %} {% elseif notification.type == constant('App\\DBAL\\Types\\NotificationType::DOCUMENT') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.document.stream.workspace.id ~ '/s/' ~ notification.event.stream.id ~ '/documents'}) %} {% elseif notification.type == constant('App\\DBAL\\Types\\NotificationType::EVENT') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.event.stream.workspace.id ~ '/s/' ~ notification.event.stream.id ~ '/events'}) %} {% elseif notification.type == constant('App\\DBAL\\Types\\NotificationType::TASK') %} {% set redirectTo = url('loader', {reactRouting: 'w/' ~ notification.task.stream.workspace.id ~ '/s/' ~ notification.task.stream.id ~ '/tasks'}) %} {% endif %} {% if not notification.creator or notification.creator.id != user.id %} {% set actor = notification.creator|default('Unknown User') %} {% endif %} {% if notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::PAYMENT_FAILED') %} {% set icon = '❌' %} {% set message = 'Payment failed! Credit card might be invalid' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::PAYMENT_SUCCEEDED') %} {% set icon = '✅' %} {% set message = 'Payment failed! Credit card might be invalid' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_CREATED') %} {% set message = '__ACTOR__ created the __TYPE__ __OBJECT__' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_UPDATED') %} {% set message = '__ACTOR__ updated the __TYPE__ __OBJECT__' %} {% set body = [] %} {% for key, values in notification.params %} {% set previousValue = values[0] %} {% set currentValue = values[1] %} {% if previousValue is iterable and currentValue is iterable %} {% set paragraph %} {{ key|title }}: {% if previousValue|length > 0 %} removed {% for index, item in previousValue %} {{ _self.formatArrayItem(item, index, previousValue|length) }} {% endfor %} {% if currentValue|length > 0 and currentValue|length > 1 %}; {% endif %} {% endif %} {% if currentValue|length > 0 %} added {% for index, item in currentValue %} {{ _self.formatArrayItem(item, index, currentValue|length) }} {% endfor %} {% endif %} . {% endset %} {% set body = body|merge([paragraph]) %} {% else %} {% set paragraph %} {{ key|title }}: was changed from {{ _self.formatValue(previousValue) }} to {{ _self.formatValue(currentValue) }}. {% endset %} {% set body = body|merge([paragraph]) %} {% endif %} {% endfor %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_DELETED') %} {% set message = '__ACTOR__ deleted the ' ~ notification.params|default({objectType: '-'}).objectType|title ~ ' ' ~ notification.params|default({objectName: '-'}).objectName|title ~ ' from __TYPE__ __OBJECT__' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_COMPLETED') %} {% set state = 'reopened' %} {% if notification.params.isCompleted|default(false) %} {% set state = 'closed' %} {% endif %} {% set message = '__ACTOR__ ' ~ state ~ ' the __TYPE__ __OBJECT__' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_DUE') %} {% set message = 'the __TYPE__ __OBJECT__ is scheduled ' ~ format_date_range_label(notification.object.startDate, notification.object.endDate, notification.object.allDay, user.dateFormat, user.timeFormat) %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::OBJECT_REMINDER') %} {% set message = 'the __TYPE__ __OBJECT__ is due now' %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::MEMBER_ADDED') %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::COLLABORATOR_ADDED') %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::COLLABORATOR_MENTIONED') %} {% set message = '__ACTOR__ mentioned you on __TYPE__ __OBJECT__' %} {% if notification.params.commentBody|default(null) %} {% set body = [notification.params.commentBody] %} {% endif %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::COMMENT_ADDED') %} {% if notification.params.commentBody|default(null) %} {% set message = '__ACTOR__ commented on __TYPE__ Thread __OBJECT__' %} {% else %} {% set message = '__ACTOR__ commented on __TYPE__ __OBJECT__' %} {% endif %} {% if notification.params.commentBody|default(null) %} {% set body = [notification.params.commentBody] %} {% endif %} {% elseif notification.command == constant('App\\DBAL\\Types\\NotificationCommandType::REACTION_ADDED') %} {% if notification.params.commentBody|default(null) %} {% set message = '__ACTOR__ reacted to __TYPE__ Thread __OBJECT__' %} {% else %} {% set message = '__ACTOR__ reacted to __TYPE__ __OBJECT__' %} {% endif %} {% if notification.params.commentBody|default(null) %} {% set body = [notification.params.commentBody] %} {% endif %} {% set icon = notification.params.reactionIcon %} {% endif %} {% if html %} {% set title %} {% if redirectTo %} {{ message|replace({ '__ACTOR__': actor, '__TYPE__': notification.type|title, '__OBJECT__': '' ~ notification.object ~ '' })|raw }} {% else %} {{ message|replace({ '__ACTOR__': actor, '__TYPE__': notification.type|title, '__OBJECT__': '' ~ notification.object ~ '' })|raw }} {% endif %} {% endset %} {% set body %} {% for paragraph in body %}

{{ paragraph|raw }}

{% endfor %} {% endset %} {{ EUI.displayCard( icon, notification.creator, title|trim, EUI.displayCommentBody({ body: body|trim }), notification.createdAt|date(user.timeFormat|default('h:i A')) ) }} {% else %} {{ notification.createdAt|date(user.timeFormat)}}: {{ message|replace({ '__ACTOR__': actor, '__TYPE__': notification.type|title, '__OBJECT__': notification.object }) }} {{ redirectTo }} {% endif %} {% endmacro %}