From b23d9a77c4093ca1aa6ea06b6b53f6d28d3ec3ba Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 17 Jul 2016 16:26:20 +0200 Subject: [PATCH] Add unsubscribe button --- dev/Model/Message.jsx | 4 +++ dev/View/User/MailBox/MessageView.js | 2 ++ .../app/libraries/MailSo/Mail/MailClient.php | 4 ++- .../app/libraries/MailSo/Mail/Message.php | 31 +++++++++++++++++++ .../MailSo/Mime/Enumerations/Header.php | 2 ++ .../0.0.0/app/libraries/RainLoop/Actions.php | 2 ++ .../app/localization/webmail/_source.en.yml | 1 + .../0.0.0/app/localization/webmail/fr_FR.yml | 1 + .../templates/Views/User/MailMessageView.html | 7 +++++ 9 files changed, 53 insertions(+), 1 deletion(-) diff --git a/dev/Model/Message.jsx b/dev/Model/Message.jsx index d34496a9b..3ba37e992 100644 --- a/dev/Model/Message.jsx +++ b/dev/Model/Message.jsx @@ -53,6 +53,7 @@ class MessageModel extends AbstractModel this.bcc = []; this.replyTo = []; this.deliveredTo = []; + this.unsubsribeLinks = []; this.newForAnimation = ko.observable(false); @@ -141,6 +142,7 @@ class MessageModel extends AbstractModel this.bcc = []; this.replyTo = []; this.deliveredTo = []; + this.unsubsribeLinks = []; this.newForAnimation(false); @@ -246,6 +248,7 @@ class MessageModel extends AbstractModel this.bcc = emailArrayFromJson(json.Bcc); this.replyTo = emailArrayFromJson(json.ReplyTo); this.deliveredTo = emailArrayFromJson(json.DeliveredTo); + this.unsubsribeLinks = json.UnsubsribeLinks; this.subject(json.Subject); if (isArray(json.SubjectParts)) @@ -716,6 +719,7 @@ class MessageModel extends AbstractModel this.bcc = message.bcc; this.replyTo = message.replyTo; this.deliveredTo = message.deliveredTo; + this.unsubsribeLinks = message.unsubsribeLinks; this.unseen(message.unseen()); this.flagged(message.flagged()); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 9d60d3715..2b909b0c1 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -290,6 +290,7 @@ function MessageViewMailBoxUserView() this.viewSize = ko.observable(''); this.viewLineAsCss = ko.observable(''); this.viewViewLink = ko.observable(''); + this.viewUnsubscribeLink = ko.observable(''); this.viewDownloadLink = ko.observable(''); this.viewUserPic = ko.observable(Consts.DATA_IMAGE_USER_DOT_PIC); this.viewUserPicVisible = ko.observable(false); @@ -374,6 +375,7 @@ function MessageViewMailBoxUserView() this.viewSize(oMessage.friendlySize()); this.viewLineAsCss(oMessage.lineAsCss()); this.viewViewLink(oMessage.viewLink()); + this.viewUnsubscribeLink(oMessage.unsubsribeLinks[0]); this.viewDownloadLink(oMessage.downloadLink()); this.viewIsImportant(oMessage.isImportant()); this.viewIsFlagged(oMessage.flagged()); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 125da70fe..22d39b28b 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -172,7 +172,8 @@ class MailClient \MailSo\Mime\Enumerations\Header::REPLY_TO, \MailSo\Mime\Enumerations\Header::DATE, \MailSo\Mime\Enumerations\Header::SUBJECT, - \MailSo\Mime\Enumerations\Header::CONTENT_TYPE + \MailSo\Mime\Enumerations\Header::CONTENT_TYPE, + \MailSo\Mime\Enumerations\Header::LIST_UNSUBSCRIBE, ), true); } @@ -213,6 +214,7 @@ class MailClient \MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO, \MailSo\Mime\Enumerations\Header::AUTHENTICATION_RESULTS, \MailSo\Mime\Enumerations\Header::X_DKIM_AUTHENTICATION_RESULTS, + \MailSo\Mime\Enumerations\Header::LIST_UNSUBSCRIBE, ), true); // // return \MailSo\Imap\Enumerations\FetchType::ENVELOPE; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php index 029b5b748..9c1c52511 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php @@ -157,6 +157,11 @@ class Message */ private $sReadReceipt; + /** + * @var array + */ + private $aUnsubsribeLinks; + /** * @var array */ @@ -223,6 +228,7 @@ class Message $this->sInReplyTo = ''; $this->sReferences = ''; + $this->aUnsubsribeLinks = array(); $this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::NOTHING; $this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL; @@ -498,6 +504,14 @@ class Message return $this->sReadReceipt; } + /** + * @return array + */ + public function UnsubsribeLinks() + { + return $this->aUnsubsribeLinks; + } + /** * @return string */ @@ -686,6 +700,23 @@ class Message $this->sReadReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO)); } + //Unsubscribe links + $this->aUnsubsribeLinks = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::LIST_UNSUBSCRIBE); + if (empty($this->aUnsubsribeLinks)) + { + $this->aUnsubsribeLinks = array(); + } + else + { + $this->aUnsubsribeLinks = explode(',', $this->aUnsubsribeLinks); + $this->aUnsubsribeLinks = array_map( + function ($link) { + return trim($link, ' <>'); + }, + $this->aUnsubsribeLinks + ); + } + $sDraftInfo = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO); if (0 < \strlen($sDraftInfo)) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Enumerations/Header.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Enumerations/Header.php index 4fa6222a3..989b6909a 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Enumerations/Header.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Enumerations/Header.php @@ -66,4 +66,6 @@ class Header const X_MSMAIL_PRIORITY = 'X-MSMail-Priority'; const IMPORTANCE = 'Importance'; const X_PRIORITY = 'X-Priority'; + + const LIST_UNSUBSCRIBE = 'List-Unsubscribe'; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 0bfdc54d0..f48bb8d27 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -9888,6 +9888,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 'Priority' => $mResponse->Priority(), 'Threads' => $mResponse->Threads(), 'Sensitivity' => $mResponse->Sensitivity(), + 'UnsubsribeLinks' => $mResponse->UnsubsribeLinks(), 'ExternalProxy' => false, 'ReadReceipt' => '' )); @@ -9966,6 +9967,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $mResult['DraftInfo'] = $mResponse->DraftInfo(); $mResult['InReplyTo'] = $mResponse->InReplyTo(); + $mResult['UnsubsribeLinks'] = $mResponse->UnsubsribeLinks(); $mResult['References'] = $mResponse->References(); $fAdditionalExternalFilter = null; diff --git a/rainloop/v/0.0.0/app/localization/webmail/_source.en.yml b/rainloop/v/0.0.0/app/localization/webmail/_source.en.yml index 9d9a4e2d9..31366026a 100644 --- a/rainloop/v/0.0.0/app/localization/webmail/_source.en.yml +++ b/rainloop/v/0.0.0/app/localization/webmail/_source.en.yml @@ -102,6 +102,7 @@ en: BUTTON_BACK: "Back" BUTTON_CLOSE: "Close" BUTTON_DELETE: "Delete" + BUTTON_UNSUBSCRIBE: "Unsubscribe from this list" BUTTON_ARCHIVE: "Archive" BUTTON_SPAM: "Spam" BUTTON_NOT_SPAM: "Not Spam" diff --git a/rainloop/v/0.0.0/app/localization/webmail/fr_FR.yml b/rainloop/v/0.0.0/app/localization/webmail/fr_FR.yml index d135eb709..aafc2ce93 100644 --- a/rainloop/v/0.0.0/app/localization/webmail/fr_FR.yml +++ b/rainloop/v/0.0.0/app/localization/webmail/fr_FR.yml @@ -102,6 +102,7 @@ fr_FR: BUTTON_BACK: "Retour" BUTTON_CLOSE: "Fermer" BUTTON_DELETE: "Supprimer" + BUTTON_UNSUBSCRIBE: "Se désabonner de cette liste" BUTTON_ARCHIVE: "Archive" BUTTON_SPAM: "Indésirable" BUTTON_NOT_SPAM: "Acceptable" diff --git a/rainloop/v/0.0.0/app/templates/Views/User/MailMessageView.html b/rainloop/v/0.0.0/app/templates/Views/User/MailMessageView.html index 34f66527a..a1480d41b 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/MailMessageView.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/MailMessageView.html @@ -147,6 +147,13 @@ +