diff --git a/internal/captcha/dwelling_captcha.go b/internal/captcha/dwelling_captcha.go index e2df229..9880208 100644 --- a/internal/captcha/dwelling_captcha.go +++ b/internal/captcha/dwelling_captcha.go @@ -15,16 +15,16 @@ const ( ) type DwellingCaptcha struct { - captcha.Captcha + captcha.BaseCaptcha } func NewDwellingCaptcha(expiry time.Duration) *DwellingCaptcha { return &DwellingCaptcha{ - Captcha: captcha.Captcha{ + BaseCaptcha: captcha.BaseCaptcha{ ExpireIn: captcha.ExpiryDate(expiry)}} } -func (c *DwellingCaptcha) generateImage(style string) *image.Image { +func (c *DwellingCaptcha) Image(style string) image.Image { isDark := style == "dark" ctx := gg.NewContext(dwImageWidth, dwImageHeight) @@ -67,14 +67,5 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image { ctx.Stroke() } - c.Image = ctx.Image() - return &c.Image -} - -func (c *DwellingCaptcha) GetImage(style string) *image.Image { - if c.Image == nil { - return c.generateImage(style) - } - - return &c.Image + return ctx.Image() }