From cc30010d3fd910fabb9b1c5d14d490e6e35b8c61 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Thu, 20 Oct 2022 22:56:28 +0400 Subject: [PATCH] Field expireIn -> expiry. Comments were redacted. --- pkg/captcha/captcha.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/captcha/captcha.go b/pkg/captcha/captcha.go index 17ddc61..8193e0c 100644 --- a/pkg/captcha/captcha.go +++ b/pkg/captcha/captcha.go @@ -20,7 +20,8 @@ func NewIntAnswer() Answer { // Captcha interface that should be implemented by a CAPTCHA. type Captcha interface { - // Image generates and returns a pointer to an image of CAPTCHA. + // Image generates an image of a CAPTCHA according to a passed style + // and returns a pointer to it. Image(style string) *image.Image // Answer returns a pregenerated answer. Answer() Answer @@ -37,14 +38,14 @@ type Captcha interface { // All derivatives that embed this struct only need to implement // an Image() method. type BaseCaptcha struct { - answer Answer - solved bool - expireIn time.Time + answer Answer + solved bool + expiry time.Time } func NewBaseCaptcha(expiry time.Duration) *BaseCaptcha { return &BaseCaptcha{ - expireIn: ExpiryDate(expiry), + expiry: ExpiryDate(expiry), } } @@ -52,8 +53,6 @@ func (c *BaseCaptcha) Image(style string) *image.Image { return nil } -// Answer generates an integer answer for a CAPTCHA or just returns -// an existing one. func (c *BaseCaptcha) Answer() Answer { if c.answer == "" { c.answer = NewIntAnswer() @@ -61,8 +60,6 @@ func (c *BaseCaptcha) Answer() Answer { return c.answer } -// Solve sets solved field to true if given answer is right and returns a result -// of a check. func (c *BaseCaptcha) Solve(answer Answer) bool { c.solved = c.answer == answer return c.solved @@ -73,7 +70,7 @@ func (c *BaseCaptcha) IsSolved() bool { } func (c *BaseCaptcha) Expiry() time.Time { - return c.expireIn + return c.expiry } // ExpiryDate returns a date when CAPTCHA expires. It adds a passed