}
/**
- * Returns a text-only version of this message.
+ * Returns a version of this message optimized for use in emails.
*
+ * @param string $mimeType Either 'text/plain' or 'text/html'
* @return string
*/
- public function getMailText() {
- return MessageParser::getInstance()->stripHTML($this->getSimplifiedFormattedMessage());
+ public function getMailText($mimeType = 'text/plain') {
+ switch ($mimeType) {
+ case 'text/plain':
+ $processor = new HtmlOutputProcessor();
+ $processor->setOutputType('text/plain');
+ $processor->process($this->message, 'com.woltlab.wcf.conversation.message', $this->messageID);
+
+ return $processor->getHtml();
+ case 'text/html':
+ return $this->getSimplifiedFormattedMessage();
+ }
+
+ throw new \LogicException('Unreachable');
}
/**
* @inheritDoc
*/
public function getEmailMessage($notificationType = 'instant') {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.conversation.mail', [
- 'conversation' => $this->userNotificationObject,
- 'author' => $this->author,
- 'notificationType' => $notificationType
- ]);
+ return [
+ 'message-id' => 'com.woltlab.wcf.conversation.notification/'.$this->getUserNotificationObject()->conversationID,
+ 'template' => 'email_notification_conversation',
+ 'application' => 'wcf'
+ ];
}
/**
{/if}{link controller='Conversation' object=$message->getConversation() isEmail=true}messageID={@$message->messageID}{/link}#message{@$message->messageID}]]></item>
<item name="wcf.user.notification.conversation.message"><![CDATA[{@$author->getAnchorTag()} hat die Konversation <a href="{link controller='Conversation' object=$conversation}{/link}">{$conversation->subject}</a> gestartet.]]></item>
<item name="wcf.user.notification.conversation.title"><![CDATA[Neue Konversation]]></item>
- <item name="wcf.user.notification.conversation.mail"><![CDATA[{@$author->username} hat die Konversation "{@$conversation->subject}" gestartet:
-{if $notificationType == 'instant'}
----------------------------------
-{@$conversation->getFirstMessage()->getMailText()}
----------------------------------
-{/if}{link controller='Conversation' object=$conversation isEmail=true}{/link}]]></item>
+ <item name="wcf.user.notification.conversation.mail.plaintext"><![CDATA[{@$event->getAuthor()->username} [URL:{link controller='User' object=$event->getAuthor() isEmail=true}{/link}] hat die Konversation „{@$event->getUserNotificationObject()->subject}“ [URL:{link controller='Conversation' object=$event->getUserNotificationObject() isEmail=true}{/link}] gestartet:]]></item>
+ <item name="wcf.user.notification.conversation.mail.html"><![CDATA[<p><a href="{link controller='User' object=$event->getAuthor() isEmail=true}{/link}">{$event->getAuthor()->username}</a> hat die Konversation <a href="{link controller='Conversation' object=$event->getUserNotificationObject() isEmail=true}{/link}">{$event->getUserNotificationObject()->subject}</a> gestartet:</p>]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation"><![CDATA[Konversationen]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation.notification.conversation"><![CDATA[Neue Konversation]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation.message.notification.conversationMessage"><![CDATA[Antwort auf bestehende Konversation]]></item>
{@$conversation->getFirstMessage()->getMailText()}
---------------------------------
{/if}{link controller='Conversation' object=$conversation isEmail=true}{/link}]]></item>
+ <item name="wcf.user.notification.conversation.mail.plaintext"><![CDATA[{@$event->getAuthor()->username} [URL:{link controller='User' object=$event->getAuthor() isEmail=true}{/link}] started the conversation “{@$event->getUserNotificationObject()->subject}” [URL:{link controller='Conversation' object=$event->getUserNotificationObject() isEmail=true}{/link}]:]]></item>
+ <item name="wcf.user.notification.conversation.mail.html"><![CDATA[<p><a href="{link controller='User' object=$event->getAuthor() isEmail=true}{/link}">{$event->getAuthor()->username}</a> started the conversation <a href="{link controller='Conversation' object=$event->getUserNotificationObject() isEmail=true}{/link}">{$event->getUserNotificationObject()->subject}</a>:</p>]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation"><![CDATA[Conversations]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation.notification.conversation"><![CDATA[Notify when I receive new conversations]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.conversation.message.notification.conversationMessage"><![CDATA[Notify when I receive replies to existing conversations]]></item>
--- /dev/null
+{if $mimeType === 'text/plain'}
+{lang}wcf.user.notification.conversation.mail.plaintext{/lang}
+
+{@$event->getUserNotificationObject()->getFirstMessage()->getMailText($mimeType)} {* this line ends with a space *}
+{else}
+ {lang}wcf.user.notification.conversation.mail.html{/lang}
+ {assign var='user' value=$event->getAuthor()}
+ {assign var='conversation' value=$event->getUserNotificationObject()}
+ {assign var='message' value=$conversation->getFirstMessage()}
+
+ {if $notificationType == 'instant'}{assign var='avatarSize' value=128}
+ {else}{assign var='avatarSize' value=64}{/if}
+ {capture assign='messageContent'}
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td><a href="{link controller='User' object=$user isEmail=true}{/link}" title="{$message->username}">{@$user->getAvatar()->getImageTag($avatarSize)}</a></td>
+ <td class="boxContent">
+ <div class="containerHeadline">
+ <h3>
+ {if $message->userID}
+ <a href="{link controller='User' object=$user isEmail=true}{/link}">{$message->username}</a>
+ {else}
+ {$message->username}
+ {/if}
+ ·
+ <small>{$message->time|plainTime}</small>
+ </h3>
+ </div>
+ <div>
+ {@$message->getMailText($mimeType)}
+ </div>
+ </td>
+ </tr>
+ </table>
+ {/capture}
+ {include file='email_paddingHelper' block=true class='box'|concat:$avatarSize content=$messageContent sandbox=true}
+{/if}