예제 #1
0
        /// <summary>
        /// Send an Private Message to the Newly Created User with
        /// his Account Info (Pass, Security Question and Answer)
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="pass">
        /// The pass.
        /// </param>
        /// <param name="userId">
        /// The user Id.
        /// </param>
        private void SendRegistrationMessageToTwitterUser(
            [NotNull] AspNetUsers user,
            [NotNull] string pass,
            [NotNull] int userId)
        {
            var subject = string.Format(
                BoardContext.Current.Get <ILocalization>().GetText("COMMON", "NOTIFICATION_ON_NEW_FACEBOOK_USER_SUBJECT"),
                BoardContext.Current.Get <BoardSettings>().Name);

            var notifyUser = new TemplateEmail
            {
                TemplateParams =
                {
                    ["{user}"]      = user.UserName,
                    ["{email}"]     = user.Email,
                    ["{pass}"]      = pass,
                    ["{forumname}"] = BoardContext.Current.Get <BoardSettings>().Name
                }
            };

            var emailBody = notifyUser.ProcessTemplate("NOTIFICATION_ON_TWITTER_REGISTER");

            var messageFlags = new MessageFlags {
                IsHtml = false, IsBBCode = true
            };

            // Send Message also as DM to Twitter.
            this.GetRepository <PMessage>().SendMessage(2, userId, subject, emailBody, messageFlags.BitValue, -1);
        }
예제 #2
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <HttpRequestBase>().QueryString.Exists("t") || !this.PageContext.ForumReadAccess ||
                !this.PageContext.BoardSettings.AllowEmailTopic)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                nameof(JavaScriptBlocks.FormValidatorJs),
                JavaScriptBlocks.FormValidatorJs(this.SendEmail.ClientID));

            this.Subject.Text = this.PageContext.PageTopicName;

            var emailTopic = new TemplateEmail
            {
                TemplateParams =
                {
                    ["{link}"] = BuildLink.GetLink(
                        ForumPages.Posts,
                        true,
                        "t={0}&name={1}",
                        this.PageContext.PageTopicID,
                        this.PageContext.PageTopicName),
                    ["{user}"] = this.Get <IUserDisplayName>().GetName(this.PageContext.User)
                }
            };

            this.Message.Text = emailTopic.ProcessTemplate("EMAILTOPIC");
        }
예제 #3
0
        /// <summary>
        /// Send an Private Message to the Newly Created User with
        /// his Account Info (Pass, Security Question and Answer)
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="pass">
        /// The pass.
        /// </param>
        /// <param name="securityAnswer">
        /// The security answer.
        /// </param>
        /// <param name="userId">
        /// The user Id.
        /// </param>
        /// <param name="oAuth">
        /// The oAUTH.
        /// </param>
        private static void SendRegistrationMessageToTwitterUser(
            [NotNull] MembershipUser user,
            [NotNull] string pass,
            [NotNull] string securityAnswer,
            [NotNull] int userId,
            OAuthTwitter oAuth)
        {
            var subject = string.Format(
                YafContext.Current.Get <ILocalization>().GetText("COMMON", "NOTIFICATION_ON_NEW_FACEBOOK_USER_SUBJECT"),
                YafContext.Current.Get <BoardSettings>().Name);

            var notifyUser = new TemplateEmail
            {
                TemplateParams =
                {
                    ["{user}"]      = user.UserName,
                    ["{email}"]     = user.Email,
                    ["{pass}"]      = pass,
                    ["{answer}"]    = securityAnswer,
                    ["{forumname}"] = YafContext.Current.Get <BoardSettings>().Name
                }
            };


            var emailBody = notifyUser.ProcessTemplate("NOTIFICATION_ON_TWITTER_REGISTER");

            var messageFlags = new MessageFlags {
                IsHtml = false, IsBBCode = true
            };

            // Send Message also as DM to Twitter.
            var tweetApi = new TweetAPI(oAuth);

            var message = $"{subject}. {YafContext.Current.Get<ILocalization>().GetText("LOGIN", "TWITTER_DM")}";

            if (YafContext.Current.Get <BoardSettings>().AllowPrivateMessages)
            {
                YafContext.Current.GetRepository <PMessage>().SendMessage(2, userId, subject, emailBody, messageFlags.BitValue, -1);
            }
            else
            {
                message = YafContext.Current.Get <ILocalization>()
                          .GetTextFormatted(
                    "LOGIN",
                    "TWITTER_DM_ACCOUNT",
                    YafContext.Current.Get <BoardSettings>().Name,
                    user.UserName,
                    pass);
            }

            try
            {
                tweetApi.SendDirectMessage(TweetAPI.ResponseFormat.json, user.UserName, message.Truncate(140));
            }
            catch (Exception ex)
            {
                YafContext.Current.Get <ILogger>().Error(ex, "Error while sending Twitter DM Message");
            }
        }
예제 #4
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <HttpRequestBase>().QueryString.Exists("t") || !this.PageContext.ForumReadAccess ||
                !this.PageContext.BoardSettings.AllowEmailTopic)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            if (this.PageContext.Settings.LockedForum == 0)
            {
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, BuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.PageCategoryName,
                    BuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            }

            this.PageLinks.AddForum(this.PageContext.PageForumID);
            this.PageLinks.AddLink(
                this.PageContext.PageTopicName,
                BuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID));

            this.Subject.Text = this.PageContext.PageTopicName;

            var emailTopic = new TemplateEmail
            {
                TemplateParams =
                {
                    ["{link}"] =
                        BuildLink.GetLinkNotEscaped(
                            ForumPages.posts,
                            true,
                            "t={0}",
                            this.PageContext.PageTopicID),
                    ["{user}"] = this.PageContext.PageUserName
                }
            };

            this.Message.Text = emailTopic.ProcessTemplate("EMAILTOPIC");
        }