コード例 #1
0
        private static string GetUnsubscribeText(NoticeMessage message, MailWhiteLabelSettings settings)
        {
            var withoutUnsubscribe = message.GetArgument("WithoutUnsubscribe");

            if (withoutUnsubscribe != null && (bool)withoutUnsubscribe.Value)
            {
                return(string.Empty);
            }

            var rootPathArgument = message.GetArgument("__VirtualRootPath");
            var rootPath         = rootPathArgument == null ? string.Empty : (string)rootPathArgument.Value;

            if (string.IsNullOrEmpty(rootPath))
            {
                return(string.Empty);
            }

            var unsubscribeLink = CoreContext.Configuration.CustomMode && CoreContext.Configuration.Personal
                                      ? GetSiteUnsubscribeLink(message, settings)
                                      : GetPortalUnsubscribeLink(message, settings);

            if (string.IsNullOrEmpty(unsubscribeLink))
            {
                return(string.Empty);
            }

            return(string.Format(NotifyTemplateResource.TextForFooterWithUnsubscribeLink, rootPath, unsubscribeLink));
        }
コード例 #2
0
        public void ApplyFormating(NoticeMessage message)
        {
            var output    = new StringBuilderTextileFormatter();
            var formatter = new TextileFormatter(output);

            if (!string.IsNullOrEmpty(message.Subject))
            {
                message.Subject = VelocityArguments.Replace(message.Subject, m => m.Result("${arg}"));
            }

            if (!string.IsNullOrEmpty(message.Body))
            {
                formatter.Format(message.Body);

                var logoMail = ConfigurationManager.AppSettings["web.logo.mail"];
                var logo     = string.IsNullOrEmpty(logoMail) ? "http://cdn.teamlab.com/media/newsletters/images/header_04.jpg" : logoMail;
                message.Body = Resources.TemplateResource.HtmlMaster.Replace("%CONTENT%", output.GetFormattedText()).Replace("%LOGO%", logo);

                var footer  = message.GetArgument("WithPhoto");
                var partner = message.GetArgument("Partner");
                var res     = String.Empty;

                if (partner != null)
                {
                    res = partner.Value.ToString();
                }
                if (String.IsNullOrEmpty(res) && footer != null)
                {
                    switch ((string)footer.Value)
                    {
                    case "photo":
                        res = Resources.TemplateResource.FooterWithPhoto;
                        break;

                    case "links":
                        res = Resources.TemplateResource.FooterWithLinks;
                        break;

                    default:
                        res = String.Empty;
                        break;
                    }
                }
                message.Body = message.Body.Replace("%FOOTER%", res);

                var mail   = message.Recipient.Addresses.FirstOrDefault(r => r.Contains("@"));
                var domain = ConfigurationManager.AppSettings["web.teamlab-site"];
                var site   = string.IsNullOrEmpty(domain) ? "http://www.teamlab.com" : domain;
                var link   = site + string.Format("/Unsubscribe.aspx?id={0}", HttpServerUtility.UrlTokenEncode(Security.Cryptography.InstanceCrypto.Encrypt(Encoding.UTF8.GetBytes(mail.ToLowerInvariant()))));
                var text   = string.Format(Resources.TemplateResource.TextForFooter, link, DateTime.UtcNow.Year);

                message.Body = message.Body.Replace("%TEXTFOOTER%", text);
            }
        }
コード例 #3
0
        private static string GetLogoImg(NoticeMessage message, string imagePath)
        {
            string logoImg;

            if (CoreContext.Configuration.Personal && !CoreContext.Configuration.CustomMode)
            {
                logoImg = imagePath + "/mail_logo.png";
            }
            else
            {
                logoImg = ConfigurationManagerExtension.AppSettings["web.logo.mail"];
                if (String.IsNullOrEmpty(logoImg))
                {
                    var logo = message.GetArgument("LetterLogo");
                    if (logo != null && (string)logo.Value != "")
                    {
                        logoImg = (string)logo.Value;
                    }
                    else
                    {
                        logoImg = imagePath + "/mail_logo.png";
                    }
                }
            }

            return(logoImg);
        }
コード例 #4
0
        private string GetLogoImg(NoticeMessage message)
        {
            string logoImg;

            if (CoreBaseSettings.Personal && !CoreBaseSettings.CustomMode)
            {
                logoImg = "https://static.onlyoffice.com/media/newsletters/images-v10/mail_logo.png";
            }
            else
            {
                logoImg = Configuration["web:logo:mail"];
                if (string.IsNullOrEmpty(logoImg))
                {
                    var logo = message.GetArgument("LetterLogo");
                    if (logo != null && (string)logo.Value != "")
                    {
                        logoImg = (string)logo.Value;
                    }
                    else
                    {
                        logoImg = "https://static.onlyoffice.com/media/newsletters/images-v10/mail_logo.png";
                    }
                }
            }

            return(logoImg);
        }
コード例 #5
0
        private string GetLogoImg(NoticeMessage message, string imagePath)
        {
            string logoImg;

            if (CoreBaseSettings.Personal && !CoreBaseSettings.CustomMode)
            {
                logoImg = imagePath + "/mail_logo.png";
            }
            else
            {
                logoImg = Configuration["web:logo:mail"];
                if (string.IsNullOrEmpty(logoImg))
                {
                    var logo = message.GetArgument("LetterLogo");
                    if (logo != null && (string)logo.Value != "")
                    {
                        logoImg = (string)logo.Value;
                    }
                    else
                    {
                        logoImg = imagePath + "/mail_logo.png";
                    }
                }
            }

            return(logoImg);
        }
コード例 #6
0
        private static string GetPortalUnsubscribeLink(NoticeMessage message, MailWhiteLabelSettings settings)
        {
            var unsubscribeLinkArgument = message.GetArgument("ProfileUrl");

            if (unsubscribeLinkArgument != null)
            {
                var unsubscribeLink = (string)unsubscribeLinkArgument.Value;

                if (!string.IsNullOrEmpty(unsubscribeLink))
                {
                    return(unsubscribeLink);
                }
            }

            return(GetSiteUnsubscribeLink(message, settings));
        }
コード例 #7
0
        private static string GetLogoText(NoticeMessage message)
        {
            var logoText = ConfigurationManagerExtension.AppSettings["web.logotext.mail"];

            if (String.IsNullOrEmpty(logoText))
            {
                var llt = message.GetArgument("LetterLogoText");
                if (llt != null && (string)llt.Value != "")
                {
                    logoText = (string)llt.Value;
                }
                else
                {
                    logoText = TenantWhiteLabelSettings.DefaultLogoText;
                }
            }

            return(logoText);
        }
コード例 #8
0
        private string GetLogoText(NoticeMessage message)
        {
            var logoText = Configuration["web:logotext:mail"];

            if (string.IsNullOrEmpty(logoText))
            {
                var llt = message.GetArgument("LetterLogoText");
                if (llt != null && (string)llt.Value != "")
                {
                    logoText = (string)llt.Value;
                }
                else
                {
                    logoText = BaseWhiteLabelSettings.DefaultLogoText;
                }
            }

            return(logoText);
        }
コード例 #9
0
        private static void InitFooter(NoticeMessage message, MailWhiteLabelSettings settings, out string footerContent, out string footerSocialContent)
        {
            footerContent       = string.Empty;
            footerSocialContent = string.Empty;

            var footer = message.GetArgument("Footer");

            if (footer == null)
            {
                return;
            }

            var footerValue = (string)footer.Value;

            if (string.IsNullOrEmpty(footerValue))
            {
                return;
            }

            switch (footerValue)
            {
            case "common":
                InitCommonFooter(settings, out footerContent, out footerSocialContent);
                break;

            case "social":
                InitSocialFooter(settings, out footerSocialContent);
                break;

            case "personal":
                footerSocialContent = NotifyTemplateResource.SocialNetworksFooterV10;
                break;

            case "personalCustomMode":
                break;

            case "opensource":
                footerContent       = NotifyTemplateResource.FooterOpensourceV10;
                footerSocialContent = NotifyTemplateResource.SocialNetworksFooterV10;
                break;
            }
        }
コード例 #10
0
        private static string GetTemplate(NoticeMessage message)
        {
            var template = NotifyTemplateResource.HtmlMaster;

            var templateTag = message.GetArgument("MasterTemplate");

            if (templateTag != null)
            {
                var templateTagValue = templateTag.Value as string;
                if (!string.IsNullOrEmpty(templateTagValue))
                {
                    var templateValue = NotifyTemplateResource.ResourceManager.GetString(templateTagValue);
                    if (!string.IsNullOrEmpty(templateValue))
                    {
                        template = templateValue;
                    }
                }
            }

            return(template);
        }
コード例 #11
0
        private static MailWhiteLabelSettings GetMailSettings(NoticeMessage message)
        {
            var mailWhiteLabelTag = message.GetArgument("MailWhiteLabelSettings");

            return(mailWhiteLabelTag == null ? null : mailWhiteLabelTag.Value as MailWhiteLabelSettings);
        }
コード例 #12
0
        private static string GetImagePath(NoticeMessage message)
        {
            var imagePathTag = message.GetArgument("ImagePath");

            return(imagePathTag == null ? string.Empty : (string)imagePathTag.Value);
        }
コード例 #13
0
        private static string GetAnalytics(NoticeMessage message)
        {
            var analyticsTag = message.GetArgument("Analytics");

            return(analyticsTag == null ? string.Empty : (string)analyticsTag.Value);
        }
コード例 #14
0
        public void ApplyFormating(NoticeMessage message)
        {
            var template       = NotifyTemplateResource.HtmlMaster;
            var isPersonalTmpl = false;

            var output    = new StringBuilderTextileFormatter();
            var formatter = new TextileFormatter(output);

            if (!string.IsNullOrEmpty(message.Subject))
            {
                message.Subject = VelocityArguments.Replace(message.Subject, m => m.Result("${arg}"));
            }

            if (string.IsNullOrEmpty(message.Body))
            {
                return;
            }

            formatter.Format(message.Body);

            var isPersonal = message.GetArgument("IsPersonal");

            if (isPersonal != null && (string)isPersonal.Value == "true")
            {
                isPersonalTmpl = true;
            }

            var templateTag = message.GetArgument("MasterTemplate");

            if (templateTag != null)
            {
                var templateTagValue = templateTag.Value as string;
                if (!string.IsNullOrEmpty(templateTagValue))
                {
                    var templateValue = NotifyTemplateResource.ResourceManager.GetString(templateTagValue);
                    if (!string.IsNullOrEmpty(templateValue))
                    {
                        template = templateValue;
                    }
                }
            }

            string logoImg;

            if (isPersonalTmpl)
            {
                logoImg = "http://cdn.teamlab.com/media/newsletters/images/mail_logo.png";
            }
            else
            {
                logoImg = ConfigurationManager.AppSettings["web.logo.mail"];
                if (String.IsNullOrEmpty(logoImg))
                {
                    var logo = message.GetArgument("LetterLogo");
                    if (logo != null && (string)logo.Value != "")
                    {
                        logoImg = (string)logo.Value;
                    }
                    else
                    {
                        logoImg = "http://cdn.teamlab.com/media/newsletters/images/mail_logo.png";
                    }
                }
            }

            var logoText = ConfigurationManager.AppSettings["web.logotext.mail"];

            if (String.IsNullOrEmpty(logoText))
            {
                var llt = message.GetArgument("LetterLogoText");
                if (llt != null && (string)llt.Value != "")
                {
                    logoText = (string)llt.Value;
                }
                else
                {
                    logoText = TenantWhiteLabelSettings.DefaultLogoText;
                }
            }

            var mailWhiteLabelTag      = message.GetArgument("MailWhiteLabelSettings");
            var mailWhiteLabelSettings = mailWhiteLabelTag == null ? null : mailWhiteLabelTag.Value as MailWhiteLabelSettings;

            message.Body = template.Replace("%CONTENT%", output.GetFormattedText())
                           .Replace("%LOGO%", logoImg)
                           .Replace("%LOGOTEXT%", logoText)
                           .Replace("%SITEURL%", mailWhiteLabelSettings == null ? MailWhiteLabelSettings.DefaultMailSiteUrl : mailWhiteLabelSettings.SiteUrl);

            var footer  = message.GetArgument("Footer");
            var partner = message.GetArgument("Partner");

            var footerContent       = string.Empty;
            var footerSocialContent = string.Empty;

            if (partner != null)
            {
                footerContent = partner.Value.ToString();
            }

            if (String.IsNullOrEmpty(footerContent) && footer != null)
            {
                switch ((string)footer.Value)
                {
                case "common":
                    InitCommonFooter(mailWhiteLabelSettings, out footerContent, out footerSocialContent);
                    break;

                case "personal":
                    footerSocialContent = NotifyTemplateResource.FooterSocial;
                    break;

                case "freecloud":
                    footerContent       = NotifyTemplateResource.FooterFreeCloud;
                    footerSocialContent = NotifyTemplateResource.FooterSocial;
                    break;

                case "opensource":
                    footerContent       = NotifyTemplateResource.FooterOpensource;
                    footerSocialContent = NotifyTemplateResource.FooterSocial;
                    break;
                }
            }

            message.Body = message.Body
                           .Replace("%FOOTER%", footerContent)
                           .Replace("%FOOTERSOCIAL%", footerSocialContent);

            var text = "";

            if (ConfigurationManager.AppSettings["core.base-domain"] != "localhost")
            {
                var noUnsubscribeLink = message.GetArgument("noUnsubscribeLink");
                if (noUnsubscribeLink == null || (string)noUnsubscribeLink.Value == "false")
                {
                    var isHosted = ConfigurationManager.AppSettings["core.payment-partners-hosted"];
                    if (String.IsNullOrEmpty(isHosted) || isHosted == "false")
                    {
                        var mail   = message.Recipient.Addresses.FirstOrDefault(r => r.Contains("@"));
                        var domain = ConfigurationManager.AppSettings["web.teamlab-site"];
                        var site   = string.IsNullOrEmpty(domain) ? "http://www.onlyoffice.com" : domain;
                        var link   = site +
                                     string.Format("/Unsubscribe.aspx?id={0}",
                                                   HttpServerUtility.UrlTokenEncode(
                                                       Security.Cryptography.InstanceCrypto.Encrypt(
                                                           Encoding.UTF8.GetBytes(mail.ToLowerInvariant()))));

                        text = string.Format(NotifyTemplateResource.TextForFooterWithUnsubscribe, link);
                    }
                }

                text += string.Format(NotifyTemplateResource.TextForFooter, DateTime.UtcNow.Year, string.Empty);
            }

            message.Body = message.Body.Replace("%TEXTFOOTER%", text);
        }
コード例 #15
0
        public void ApplyFormating(NoticeMessage message)
        {
            bool isPromoTmpl = false;
            var  output      = new StringBuilderTextileFormatter();
            var  formatter   = new TextileFormatter(output);

            if (!string.IsNullOrEmpty(message.Subject))
            {
                message.Subject = VelocityArguments.Replace(message.Subject, m => m.Result("${arg}"));
            }

            if (!string.IsNullOrEmpty(message.Body))
            {
                formatter.Format(message.Body);

                var isPromo = message.GetArgument("isPromoLetter");
                if (isPromo != null && (string)isPromo.Value == "true")
                {
                    isPromoTmpl = true;
                }

                var logoImg = "";
                if (isPromoTmpl)
                {
                    logoImg = "http://cdn.teamlab.com/media/newsletters/images/logo.png";
                }
                else
                {
                    logoImg = ConfigurationManager.AppSettings["web.logo.mail"];
                    if (String.IsNullOrEmpty(logoImg))
                    {
                        var logo = message.GetArgument("LetterLogo");
                        if (logo != null && (string)logo.Value != "")
                        {
                            logoImg = (string)logo.Value;
                        }
                        else
                        {
                            logoImg = "http://cdn.teamlab.com/media/newsletters/images/header_08.png";
                        }
                    }
                }


                var template = isPromoTmpl ? Resources.TemplateResource.HtmlMasterPromo : Resources.TemplateResource.HtmlMaster;
                message.Body = template.Replace("%CONTENT%", output.GetFormattedText()).Replace("%LOGO%", logoImg);

                var footer  = message.GetArgument("WithPhoto");
                var partner = message.GetArgument("Partner");
                var res     = String.Empty;

                if (partner != null)
                {
                    res = partner.Value.ToString();
                }


                if (String.IsNullOrEmpty(res) && footer != null)
                {
                    switch ((string)footer.Value)
                    {
                    case "photo":
                        res = Resources.TemplateResource.FooterWithPhoto;
                        break;

                    case "links":
                        res = Resources.TemplateResource.FooterWithLinks;
                        break;

                    case "personal":
                        res = Resources.TemplateResource.FooterPersonal;
                        break;

                    case "freecloud":
                        res = Resources.TemplateResource.FooterFreeCloud;
                        break;

                    default:
                        res = String.Empty;
                        break;
                    }
                }
                message.Body = message.Body.Replace("%FOOTER%", res);


                var text = "";

                var noUnsubscribeLink = message.GetArgument("noUnsubscribeLink");
                if (noUnsubscribeLink == null || (string)noUnsubscribeLink.Value == "false")
                {
                    var isHosted = ConfigurationManager.AppSettings["core.payment-partners-hosted"];
                    if (String.IsNullOrEmpty(isHosted) || isHosted == "false")
                    {
                        var mail   = message.Recipient.Addresses.FirstOrDefault(r => r.Contains("@"));
                        var domain = ConfigurationManager.AppSettings["web.teamlab-site"];
                        var site   = string.IsNullOrEmpty(domain) ? "http://www.onlyoffice.com" : domain;
                        var link   = site + string.Format("/Unsubscribe.aspx?id={0}", HttpServerUtility.UrlTokenEncode(Security.Cryptography.InstanceCrypto.Encrypt(Encoding.UTF8.GetBytes(mail.ToLowerInvariant()))));

                        text = string.Format(Resources.TemplateResource.TextForFooterWithUnsubscribe, link);
                    }
                }

                text        += string.Format(Resources.TemplateResource.TextForFooter, DateTime.UtcNow.Year, string.Empty);
                message.Body = message.Body.Replace("%TEXTFOOTER%", text);
            }
        }