Files
CatsOfMastodonGo/internal/services/imgKitHelper.go
Mohammad Mahdi f136ae58b3 Refactor: Implement uber-go/fx dependency injection
- Replace global variable pattern with proper dependency injection
- Add uber-go/fx for automatic dependency resolution
- Refactor all services and handlers to use constructor injection
- Eliminate fragile initialization order dependencies
- Improve testability and modularity
- Add structured logging with zap

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2025-09-16 11:41:01 +03:30

25 lines
617 B
Go

package services
import "CatsOfMastodonBotGo/internal/config"
type ImgKitHelper struct {
cfg *config.Config
}
func NewImgKitHelper(cfg *config.Config) *ImgKitHelper {
return &ImgKitHelper{cfg: cfg}
}
func (ikh *ImgKitHelper) GetPreviewUrl(url string) string {
if ikh.cfg.ImageKitId == "" {
return url
}
return "https://ik.imagekit.io/" + ikh.cfg.ImageKitId + "/tr:w-500,h-500,c-at_max,f-webp,q-50/" + url
}
func (ikh *ImgKitHelper) GetRemoteUrl(url string) string {
if ikh.cfg.ImageKitId == "" {
return url
}
return "https://ik.imagekit.io/" + ikh.cfg.ImageKitId + "/tr:q-70,dpr-auto,f-webp/" + url
}