예제 #1
0
        private ContactSettings GetSettings()
        {
            var settings = new ContactSettings();

            settings.RecaptchaSettings.RecaptchaKey = Environment.GetEnvironmentVariable("RecaptchaKey");
            settings.RecaptchaSettings.Enabled      = Environment.GetEnvironmentVariable("RecaptchaEnabled") == "true";

            settings.PostSettings.PostURL = Environment.GetEnvironmentVariable("PostURL");
            settings.PostSettings.EncType = PostEncType.JSON;
            settings.PostSettings.Enabled = Environment.GetEnvironmentVariable("PostEnabled") == "true";

            settings.EmailSettings.MailServer     = Environment.GetEnvironmentVariable("MailServer");
            settings.EmailSettings.Username       = Environment.GetEnvironmentVariable("Username");
            settings.EmailSettings.Password       = Environment.GetEnvironmentVariable("Password");
            settings.EmailSettings.MailSender     = Environment.GetEnvironmentVariable("MailSender");
            settings.EmailSettings.MailSenderName = Environment.GetEnvironmentVariable("MailSenderName");
            settings.EmailSettings.MailReciever   = Environment.GetEnvironmentVariable("MailReciever");
            settings.EmailSettings.MailPort       = Convert.ToInt32(Environment.GetEnvironmentVariable("MailPort"));
            var sec = Environment.GetEnvironmentVariable("MailSecurity");

            settings.EmailSettings.MailSecurity  = sec == "2" ? MailSecurity.TLS : (sec == "1" ? MailSecurity.SSL : MailSecurity.None);
            settings.EmailSettings.SubjectPrefix = Environment.GetEnvironmentVariable("SubjectPrefix");
            settings.EmailSettings.Enabled       = Environment.GetEnvironmentVariable("MailEnabled") == "true";

            return(settings);
        }
예제 #2
0
        public ContactResult Submit(ContactModel contact, ContactSettings contactSettings)
        {
            var result = new ContactResult();
            if (contact == null) throw new ArgumentNullException("Missing contact form data");
            if (contactSettings == null) throw new ArgumentNullException("Missing settings");

            if (logger != null) logger.LogInformation("Contact: {0} / {1} / {2} [Email: {3}, Post: {4}, Recaptcha: {5}]",
                contact.ContactName, contact.Email, contact.Phone, contactSettings.EmailSettings?.Enabled,
                contactSettings.PostSettings?.Enabled, contactSettings.RecaptchaSettings?.Enabled);

            if (contactSettings.RecaptchaSettings != null
                && contactSettings.RecaptchaSettings.Enabled
                && !string.IsNullOrEmpty(contactSettings.RecaptchaSettings.RecaptchaKey))
            {
                // Check Recaptcha
                var recaptchaService = new RecaptchaService();
                result.RecaptchaResult = recaptchaService.Validate(contactSettings.RecaptchaSettings, logger);
                if (result.RecaptchaResult.ServiceResultType != ServiceResultType.Success) return result;  // Stop processing immediately
            }

            if (contactSettings.EmailSettings != null && contactSettings.EmailSettings.Enabled)
            {
                var emailService = new EmailService();
                result.EmailResult = emailService.SendEmail(contact, contactSettings.EmailSettings, logger);
            }

            if (contactSettings.PostSettings != null && contactSettings.PostSettings.Enabled && !string.IsNullOrEmpty(contactSettings.PostSettings.PostURL))
            {
                var postService = new PostService();
                result.PostResult = postService.Post(contact, contactSettings.PostSettings, logger);
            }
            return result;
        }
예제 #3
0
        public string GetResultHTML(ContactResult result, ContactSettings contactSettings)
        {
            StringBuilder sbResult = new StringBuilder();
            sbResult.AppendLine(result.Success ? "Successfully executed: <br />" : "Execution result: <br />");
            if (result.EmailResult != null && result.EmailResult.ServiceResultType != ServiceResultType.None)
                sbResult.AppendFormat("{0} <br/>", result.EmailResult.Message);
            if (result.PostResult != null && result.PostResult.ServiceResultType != ServiceResultType.None)
                sbResult.AppendFormat("{0} <br/>", result.PostResult.Message);
            if (result.RecaptchaResult != null && result.RecaptchaResult.ServiceResultType != ServiceResultType.Success)
                sbResult.AppendFormat("Invalid reCAPTCHA: {0} <br/>", result.RecaptchaResult.Message);

            if (!string.IsNullOrEmpty(contactSettings.PostSettings.RedirectURL) && contactSettings.PostSettings.RedirectSeconds >= 0)
            {
                var redirectURL = string.Format(contactSettings.PostSettings.RedirectURL, result.Success ? "1" : "0");
                // Show 'Click to continue'
                sbResult.AppendFormat("<a href='{0}'>{1}</a>", redirectURL, contactSettings.PostSettings.RedirectText);

                if (contactSettings.PostSettings.RedirectSeconds > 0)
                {
                    // JS redirect after RedirectSeconds
                    sbResult.AppendFormat("\r\n<script type='text/javascript'>setTimeout(function() {{document.location.href='{0}'}}, {1})</script>",
                        redirectURL, contactSettings.PostSettings.RedirectSeconds * 1000);
                }
            }
            return sbResult.ToString();
        }
예제 #4
0
 public SetContactSettingsResponse SetContactSetting(ContactSettings contactSettings)
 {
     return(PostProtoPayload <Request, SetContactSettingsResponse>(RequestType.SetContactSettings, new SetContactSettingsMessage()
     {
         ContactSettings = contactSettings
     }));
 }
예제 #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CreationTimestampMs != 0L)
            {
                hash ^= CreationTimestampMs.GetHashCode();
            }
            if (Username.Length != 0)
            {
                hash ^= Username.GetHashCode();
            }
            if (Team != 0)
            {
                hash ^= Team.GetHashCode();
            }
            hash ^= tutorialState_.GetHashCode();
            if (avatar_ != null)
            {
                hash ^= Avatar.GetHashCode();
            }
            if (MaxPokemonStorage != 0)
            {
                hash ^= MaxPokemonStorage.GetHashCode();
            }
            if (MaxItemStorage != 0)
            {
                hash ^= MaxItemStorage.GetHashCode();
            }
            if (dailyBonus_ != null)
            {
                hash ^= DailyBonus.GetHashCode();
            }
            if (equippedBadge_ != null)
            {
                hash ^= EquippedBadge.GetHashCode();
            }
            if (contactSettings_ != null)
            {
                hash ^= ContactSettings.GetHashCode();
            }
            hash ^= currencies_.GetHashCode();
            if (RemainingCodenameClaims != 0)
            {
                hash ^= RemainingCodenameClaims.GetHashCode();
            }
            if (buddyPokemon_ != null)
            {
                hash ^= BuddyPokemon.GetHashCode();
            }
            if (BattleLockoutEndMs != 0L)
            {
                hash ^= BattleLockoutEndMs.GetHashCode();
            }
            if (secondaryPlayerAvatar_ != null)
            {
                hash ^= SecondaryPlayerAvatar.GetHashCode();
            }
            return(hash);
        }
예제 #6
0
        public virtual IActionResult ResetContact()
        {
            var model = new ContactSettings();

            Engine.Settings.Set(model);
            return(RedirectWithResetMessage("Contact"));
        }
예제 #7
0
 public void Clone(Contact contact)
 {
     settings                  = contact.settings;
     body1                     = contact.body1;
     body2                     = contact.body2;
     normal                    = contact.normal;
     tangent                   = contact.tangent;
     realRelPos1               = contact.realRelPos1;
     realRelPos2               = contact.realRelPos2;
     relativePos1              = contact.relativePos1;
     relativePos2              = contact.relativePos2;
     p1                        = contact.p1;
     p2                        = contact.p2;
     accumulatedNormalImpulse  = contact.accumulatedNormalImpulse;
     accumulatedTangentImpulse = contact.accumulatedTangentImpulse;
     penetration               = contact.penetration;
     initialPen                = contact.initialPen;
     staticFriction            = contact.staticFriction;
     dynamicFriction           = contact.dynamicFriction;
     restitution               = contact.restitution;
     friction                  = contact.friction;
     massNormal                = contact.massNormal;
     massTangent               = contact.massTangent;
     restitutionBias           = contact.restitutionBias;
     newContact                = contact.newContact;
     treatBody1AsStatic        = contact.treatBody1AsStatic;
     treatBody2AsStatic        = contact.treatBody2AsStatic;
     body1IsMassPoint          = contact.body1IsMassPoint;
     body2IsMassPoint          = contact.body2IsMassPoint;
     lostSpeculativeBounce     = contact.lostSpeculativeBounce;
     speculativeVelocity       = contact.speculativeVelocity;
     lastTimeStep              = contact.lastTimeStep;
 }
예제 #8
0
        public async Task <SetContactSettingsResponse> SetContactSetting(ContactSettings contactSettings)
        {
            var setContactSettingRequest = new Request
            {
                RequestType    = RequestType.SetContactSettings,
                RequestMessage = new SetContactSettingsMessage
                {
                    ContactSettings = contactSettings
                }.ToByteString()
            };

            var request = await GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(setContactSettingRequest, Client)).ConfigureAwait(false);

            Tuple <SetContactSettingsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response =
                await
                PostProtoPayload
                <Request, SetContactSettingsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse,
                 CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request).ConfigureAwait(false);

            CheckChallengeResponse checkChallengeResponse = response.Item2;

            CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse);

            GetInventoryResponse getInventoryResponse = response.Item4;

            CommonRequest.ProcessGetInventoryResponse(Client, getInventoryResponse);

            DownloadSettingsResponse downloadSettingsResponse = response.Item6;

            CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse);

            return(response.Item1);
        }
예제 #9
0
 public async Task <SetContactSettingsResponse> SetContactSetting(ContactSettings contactSettings)
 {
     return(await PostProtoPayload <Request, SetContactSettingsResponse>(RequestType.SetContactSettings, new SetContactSettingsMessage()
     {
         ContactSettings = contactSettings
     }));
 }
예제 #10
0
 public ContactController(IEmailSender emailSender,
                          IOptions <ContactSettings> contactSettings,
                          ILogger <ContactController> logger)
 {
     _emailSender     = emailSender;
     _contactSettings = contactSettings.Value;
     _logger          = logger;
 }
예제 #11
0
        /// <summary>
        /// Initializes a contact.
        /// </summary>
        /// <param name="body1">The first body.</param>
        /// <param name="body2">The second body.</param>
        /// <param name="point1">The collision point in worldspace</param>
        /// <param name="point2">The collision point in worldspace</param>
        /// <param name="n">The normal pointing to body2.</param>
        /// <param name="penetration">The estimated penetration depth.</param>
        public void Initialize(RigidBody body1, RigidBody body2, ref TSVector point1, ref TSVector point2, ref TSVector n,
                               FP penetration, bool newContact, ContactSettings settings)
        {
            this.body1  = body1;  this.body2 = body2;
            this.normal = n; normal.Normalize();
            this.p1     = point1; this.p2 = point2;

            this.newContact = newContact;

            TSVector.Subtract(ref p1, ref body1.position, out relativePos1);
            TSVector.Subtract(ref p2, ref body2.position, out relativePos2);
            TSVector.Transform(ref relativePos1, ref body1.invOrientation, out realRelPos1);
            TSVector.Transform(ref relativePos2, ref body2.invOrientation, out realRelPos2);

            this.initialPen  = penetration;
            this.penetration = penetration;

            body1IsMassPoint = body1.isParticle;
            body2IsMassPoint = body2.isParticle;

            // Material Properties
            if (newContact)
            {
                treatBody1AsStatic = body1.isStatic;
                treatBody2AsStatic = body2.isStatic;

                CBFrame.Utils.Logger.Debug("line812 body2.isStatic:" + body2.isStatic + ",body1.isStatic:" + body1.isStatic);

                accumulatedNormalImpulse  = FP.Zero;
                accumulatedTangentImpulse = FP.Zero;

                lostSpeculativeBounce = FP.Zero;

                switch (settings.MaterialCoefficientMixing)
                {
                case ContactSettings.MaterialCoefficientMixingType.TakeMaximum:
                    staticFriction  = TSMath.Max(body1.staticFriction, body2.staticFriction);
                    dynamicFriction = TSMath.Max(body1.staticFriction, body2.staticFriction);
                    restitution     = TSMath.Max(body1.restitution, body2.restitution);
                    break;

                case ContactSettings.MaterialCoefficientMixingType.TakeMinimum:
                    staticFriction  = TSMath.Min(body1.staticFriction, body2.staticFriction);
                    dynamicFriction = TSMath.Min(body1.staticFriction, body2.staticFriction);
                    restitution     = TSMath.Min(body1.restitution, body2.restitution);
                    break;

                case ContactSettings.MaterialCoefficientMixingType.UseAverage:
                    staticFriction  = (body1.staticFriction + body2.staticFriction) * FP.Half;
                    dynamicFriction = (body1.staticFriction + body2.staticFriction) * FP.Half;
                    restitution     = (body1.restitution + body2.restitution) * FP.Half;
                    break;
                }
            }

            this.settings = settings;
        }
예제 #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contactSettings"></param>
        /// <returns></returns>
        public bool QueueSetContactSettingRequest(ContactSettings contactSettings)
        {
            var message = new SetContactSettingsMessage
            {
                ContactSettings = contactSettings
            };

            return(Client.QueueRequest(RequestType.SetContactSettings, message));
        }
예제 #13
0
        public HomeController(IJournalRepository journalRepository, IMailSender mailSender, ContactSettings contactSettings, IUserProfileRepository userProfileRepository, IAuthentication authentication)
            : base(userProfileRepository, authentication)
        {
            Requires.NotNull(mailSender, "mailSender");
            Requires.NotNull(contactSettings, "contactSettings");

            this.journalRepository = journalRepository;
            this.mailSender        = mailSender;
            this.contactSettings   = contactSettings;
        }
예제 #14
0
        public void ToMailMessageWithNullContactSettingsThrowsArgumentNullException()
        {
            // Arrange
            var             contactViewModel    = CreateContactViewModel();
            ContactSettings nullContactSettings = null;

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => contactViewModel.ToMailMessage(nullContactSettings));
        }
예제 #15
0
        public virtual IActionResult Contact()
        {
            _cache.Remove(typeof(ContactSettings).ToString());
            ContactSettings model = Engine.Settings.Contact;

            if (model == null)
            {
                model = new ContactSettings();
            }
            return(View(model));
        }
예제 #16
0
        public MailMessage ToMailMessage(ContactSettings contactSettings)
        {
            Requires.NotNull(contactSettings, "contactSettings");
            Validator.ValidateObject(this, new ValidationContext(this));

            return(new MailMessage(new MailAddress(this.Email, this.Name), new MailAddress(contactSettings.ContactFormTo))
            {
                Body = this.Message,
                Subject = contactSettings.ContactFormSubject
            });
        }
예제 #17
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CreationTimestampMs != 0L)
            {
                hash ^= CreationTimestampMs.GetHashCode();
            }
            if (Username.Length != 0)
            {
                hash ^= Username.GetHashCode();
            }
            if (Team != global::POGOProtos.Enums.TeamColor.Neutral)
            {
                hash ^= Team.GetHashCode();
            }
            hash ^= tutorialState_.GetHashCode();
            if (avatar_ != null)
            {
                hash ^= Avatar.GetHashCode();
            }
            if (MaxPokemonStorage != 0)
            {
                hash ^= MaxPokemonStorage.GetHashCode();
            }
            if (MaxItemStorage != 0)
            {
                hash ^= MaxItemStorage.GetHashCode();
            }
            if (dailyBonus_ != null)
            {
                hash ^= DailyBonus.GetHashCode();
            }
            if (equippedBadge_ != null)
            {
                hash ^= EquippedBadge.GetHashCode();
            }
            if (contactSettings_ != null)
            {
                hash ^= ContactSettings.GetHashCode();
            }
            hash ^= currencies_.GetHashCode();
            if (RemainingCodenameClaims != 0)
            {
                hash ^= RemainingCodenameClaims.GetHashCode();
            }
            if (buddyPokemon_ != null)
            {
                hash ^= BuddyPokemon.GetHashCode();
            }
            return(hash);
        }
예제 #18
0
        public void Email_Disabled_Post_Enabled_Json_No_Captcha()
        {
            var contactSettings = new ContactSettings
            {
                EmailSettings     = EmailSettingsBuilder.GetDisabled(),
                PostSettings      = PostSettingsBuilder.GetEnabled(PostEncType.JSON, 0),
                RecaptchaSettings = RecaptchaSettingsBuilder.GetDisabled()
            };

            var result = contactService.Submit(contact, contactSettings);

            Assert.Equal(ServiceResultType.Success, result.PostResult.ServiceResultType);
        }
예제 #19
0
        public void Email_Disabled_Post_Disabled_No_Captcha()
        {
            var contact         = ContactModelBuilder.GetContactNoCaptcha();
            var contactSettings = new ContactSettings {
                EmailSettings     = EmailSettingsBuilder.GetDisabled(),
                PostSettings      = PostSettingsBuilder.GetDisabled(),
                RecaptchaSettings = RecaptchaSettingsBuilder.GetDisabled()
            };

            var result = contactService.Submit(contact, contactSettings);

            Assert.True(result.Success);
        }
예제 #20
0
        public void Email_Disabled_Post_Disabled_Captcha_Bad()
        {
            var contact         = ContactModelBuilder.GetContactNoCaptcha();
            var contactSettings = new ContactSettings
            {
                EmailSettings     = EmailSettingsBuilder.GetDisabled(),
                PostSettings      = PostSettingsBuilder.GetDisabled(),
                RecaptchaSettings = RecaptchaSettingsBuilder.GetEnabledBad()
            };

            var result = contactService.Submit(contact, contactSettings);

            Assert.False(result.Success);
            Assert.Equal(ServiceResultType.Error, result.RecaptchaResult.ServiceResultType);
        }
예제 #21
0
 public virtual IActionResult Contact(ContactSettings model)
 {
     try
     {
         Engine.Settings.Set(model);
         SaveMessage = "Settings saved!";
         MessageType = AlertType.Success;
     }
     catch (Exception ex)
     {
         SaveMessage = "Error saving: " + ex.Message;
         MessageType = AlertType.Danger;
     }
     return(View(model));
 }
예제 #22
0
        public HomeController(
            IBaseScoreCardRepository baseScoreCardRepository,
            IValuationScoreCardRepository valuationScoreCardRepository,
            IJournalRepository journalRepository, IMailSender mailSender,
            ContactSettings contactSettings,
            IUserProfileRepository userProfileRepository,
            IAuthentication authentication)
            : base(baseScoreCardRepository, valuationScoreCardRepository, userProfileRepository, authentication)
        {
            Requires.NotNull(journalRepository, nameof(journalRepository));
            Requires.NotNull(mailSender, nameof(mailSender));
            Requires.NotNull(contactSettings, nameof(contactSettings));

            this.journalRepository = journalRepository;
            this.mailSender        = mailSender;
            this.contactSettings   = contactSettings;
        }
예제 #23
0
            private async Task SaveContact(SubmissionData submission, ContactSettings settings)
            {
                var nameField  = settings.NameField ?? "name";
                var emailField = settings.EmailField ?? "email";
                var phoneField = settings.PhoneField ?? "phone";

                var contact = new Contact
                {
                    PartitionKey = submission.SiteUrl,
                    RowKey       = submission.Id,
                    Name         = submission.ValueOf(nameField),
                    Email        = submission.ValueOf(emailField),
                    Phone        = submission.ValueOf(phoneField),
                    Details      = JsonConvert.SerializeObject(submission.Fields),
                };

                await _contactsTable.InsertAsync(contact);
            }
예제 #24
0
        public MailMessage ToMailMessage(ContactSettings contactSettings)
        {
            Requires.NotNull(contactSettings, nameof(contactSettings));
            Validator.ValidateObject(this, new ValidationContext(this));

            var mailMessage = new MailMessage(new MailAddress(this.Email, this.Name), new MailAddress(contactSettings.ContactFormTo))
            {
                Body    = this.Message,
                Subject = contactSettings.ContactFormSubject
            };

            if (File != null)
            {
                mailMessage.Attachments.Add(new Attachment(File.InputStream, File.FileName));
            }

            return(mailMessage);
        }
예제 #25
0
 private static HomeController CreateHomeController(
     IBaseScoreCardRepository baseScoreCardRepository           = null,
     IValuationScoreCardRepository valuationScoreCardRepository = null,
     IJournalRepository journalRepository = null,
     IMailSender mailSender          = null,
     ContactSettings contactSettings = null,
     IUserProfileRepository userProfileRepository = null,
     IAuthentication authentication = null)
 {
     return(new HomeController(
                baseScoreCardRepository ?? Mock.Of <IBaseScoreCardRepository>(),
                valuationScoreCardRepository ?? Mock.Of <IValuationScoreCardRepository>(),
                journalRepository ?? Mock.Of <IJournalRepository>(),
                mailSender ?? Mock.Of <IMailSender>(),
                contactSettings ?? CreateContactSettings(),
                userProfileRepository ?? Mock.Of <IUserProfileRepository>(),
                authentication ?? Mock.Of <IAuthentication>()));
 }
예제 #26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CreationTimestampMs != 0L)
            {
                hash ^= CreationTimestampMs.GetHashCode();
            }
            if (Username.Length != 0)
            {
                hash ^= Username.GetHashCode();
            }
            if (Team != 0)
            {
                hash ^= Team.GetHashCode();
            }
            hash ^= tutorialState_.GetHashCode();
            if (avatar_ != null)
            {
                hash ^= Avatar.GetHashCode();
            }
            if (MaxPokemonStorage != 0)
            {
                hash ^= MaxPokemonStorage.GetHashCode();
            }
            if (MaxItemStorage != 0)
            {
                hash ^= MaxItemStorage.GetHashCode();
            }
            if (dailyBonus_ != null)
            {
                hash ^= DailyBonus.GetHashCode();
            }
            if (equippedBadge_ != null)
            {
                hash ^= EquippedBadge.GetHashCode();
            }
            if (contactSettings_ != null)
            {
                hash ^= ContactSettings.GetHashCode();
            }
            hash ^= currencies_.GetHashCode();
            return(hash);
        }
예제 #27
0
 public async Task <SetContactSettingsResponse> TutorialSetContactSettings(ContactSettings contactSettings)
 {
     return(await Context.Client.Player.SetContactSetting(contactSettings));
 }
예제 #28
0
 public async Task<SetContactSettingsResponse> SetContactSetting(ContactSettings contactSettings)
 {
     return await PostProtoPayload<Request, SetContactSettingsResponse>(RequestType.SetContactSettings, new SetContactSettingsMessage()
     {
         ContactSettings = contactSettings
     });
 }
예제 #29
0
 public void MergeFrom(PlayerData other)
 {
     if (other == null)
     {
         return;
     }
     if (other.CreationTimestampMs != 0L)
     {
         CreationTimestampMs = other.CreationTimestampMs;
     }
     if (other.Username.Length != 0)
     {
         Username = other.Username;
     }
     if (other.Team != 0)
     {
         Team = other.Team;
     }
     tutorialState_.Add(other.tutorialState_);
     if (other.avatar_ != null)
     {
         if (avatar_ == null)
         {
             avatar_ = new global::POGOProtos.Data.Player.PlayerAvatar();
         }
         Avatar.MergeFrom(other.Avatar);
     }
     if (other.MaxPokemonStorage != 0)
     {
         MaxPokemonStorage = other.MaxPokemonStorage;
     }
     if (other.MaxItemStorage != 0)
     {
         MaxItemStorage = other.MaxItemStorage;
     }
     if (other.dailyBonus_ != null)
     {
         if (dailyBonus_ == null)
         {
             dailyBonus_ = new global::POGOProtos.Data.Player.DailyBonus();
         }
         DailyBonus.MergeFrom(other.DailyBonus);
     }
     if (other.equippedBadge_ != null)
     {
         if (equippedBadge_ == null)
         {
             equippedBadge_ = new global::POGOProtos.Data.Player.EquippedBadge();
         }
         EquippedBadge.MergeFrom(other.EquippedBadge);
     }
     if (other.contactSettings_ != null)
     {
         if (contactSettings_ == null)
         {
             contactSettings_ = new global::POGOProtos.Data.Player.ContactSettings();
         }
         ContactSettings.MergeFrom(other.ContactSettings);
     }
     currencies_.Add(other.currencies_);
     if (other.RemainingCodenameClaims != 0)
     {
         RemainingCodenameClaims = other.RemainingCodenameClaims;
     }
     if (other.buddyPokemon_ != null)
     {
         if (buddyPokemon_ == null)
         {
             buddyPokemon_ = new global::POGOProtos.Data.BuddyPokemon();
         }
         BuddyPokemon.MergeFrom(other.BuddyPokemon);
     }
     if (other.BattleLockoutEndMs != 0L)
     {
         BattleLockoutEndMs = other.BattleLockoutEndMs;
     }
 }
예제 #30
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "options", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            ContactModel contact;
            var          isJson = req.ContentType.StartsWith("application/json");

            if (isJson)
            {
                string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
                contact = JsonConvert.DeserializeObject <ContactModel>(requestBody);
            }
            else
            {
                contact = new ContactModel
                {
                    ContactName       = req.Form["ContactName"],
                    Email             = req.Form["Email"],
                    Phone             = req.Form["Phone"],
                    Subject           = req.Form["Subject"],
                    Category          = req.Form["Category"],
                    Message           = req.Form["Message"],
                    RecaptchaResponse = req.Form["g-recaptcha-response"]
                };
            }

            if (contact == null)
            {
                return(new BadRequestObjectResult("Please pass a contact form data"));
            }
            else
            {
                // Get settings
                var config = new ConfigurationBuilder()
                             .SetBasePath(context.FunctionAppDirectory)
                             .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                             .AddEnvironmentVariables()
                             .Build();
                var contactSettings = new ContactSettings();
                config.GetSection("ContactSettings").Bind(contactSettings);

                var contactService = new ContactFormService(log);
                contactSettings.RecaptchaSettings.RecaptchaResponse = contact.RecaptchaResponse;
                var result = contactService.Submit(contact, contactSettings);

                if (isJson)
                {
                    return((ActionResult) new OkObjectResult(result));
                }
                else
                {
                    // Return 'text/html'
                    if (!string.IsNullOrEmpty(contactSettings.PostSettings.RedirectURL) && contactSettings.PostSettings.RedirectSeconds == -1)
                    {
                        return(new RedirectResult(string.Format(contactSettings.PostSettings.RedirectURL, result.Success ? "1" : "0")));
                    }
                    else
                    {
                        return new ContentResult {
                                   Content = contactService.GetResultHTML(result, contactSettings), ContentType = "text/html", StatusCode = 200
                        }
                    };
                }
            }
        }
    }
예제 #31
0
 public ContactController(ContactFormService contactFormService, IOptions <ContactSettings> contactSettings)
 {
     this.contactFormService = contactFormService;
     this.contactSettings    = contactSettings.Value;
 }
예제 #32
0
 private static HomeController CreateHomeController(
     IBaseScoreCardRepository baseScoreCardRepository = null,
     IValuationScoreCardRepository valuationScoreCardRepository = null,
     IJournalRepository journalRepository = null,
     IMailSender mailSender = null,
     ContactSettings contactSettings = null,
     IUserProfileRepository userProfileRepository = null,
     IAuthentication authentication = null)
 {
     return new HomeController(
         baseScoreCardRepository ?? Mock.Of<IBaseScoreCardRepository>(),
         valuationScoreCardRepository ?? Mock.Of<IValuationScoreCardRepository>(),
         journalRepository ?? Mock.Of<IJournalRepository>(),
         mailSender ?? Mock.Of<IMailSender>(),
         contactSettings ?? CreateContactSettings(),
         userProfileRepository ?? Mock.Of<IUserProfileRepository>(),
         authentication ?? Mock.Of<IAuthentication>());
 }