feat: enhance schedule publish account handling and caching mechanisms
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
goredis "github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/geo-platform/tenant-api/internal/shared/auth"
|
||||
sharedcache "github.com/geo-platform/tenant-api/internal/shared/cache"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/messaging/rabbitmq"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/response"
|
||||
"github.com/geo-platform/tenant-api/internal/tenant/repository"
|
||||
@@ -27,6 +28,7 @@ type DesktopAccountService struct {
|
||||
pool *pgxpool.Pool
|
||||
repo repository.DesktopAccountRepository
|
||||
clientRepo repository.DesktopClientRepository
|
||||
cache sharedcache.Cache
|
||||
redis *goredis.Client
|
||||
rabbitMQ *rabbitmq.Client
|
||||
now func() time.Time
|
||||
@@ -49,6 +51,11 @@ func NewDesktopAccountService(
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DesktopAccountService) WithCache(c sharedcache.Cache) *DesktopAccountService {
|
||||
s.cache = c
|
||||
return s
|
||||
}
|
||||
|
||||
type DesktopAccountView struct {
|
||||
ID string `json:"id"`
|
||||
Platform string `json:"platform"`
|
||||
@@ -389,6 +396,7 @@ func (s *DesktopAccountService) Tombstone(ctx context.Context, client *repositor
|
||||
}
|
||||
|
||||
view := s.buildDesktopAccountView(account, nil, nil, nil, nil)
|
||||
invalidateScheduleTaskCaches(ctx, s.cache, client.TenantID, nil)
|
||||
return &view, nil
|
||||
}
|
||||
|
||||
@@ -451,6 +459,7 @@ func (s *DesktopAccountService) DeleteForActor(ctx context.Context, actor auth.A
|
||||
}
|
||||
|
||||
view := s.buildDesktopAccountView(account, nil, nil, nil, nil)
|
||||
invalidateScheduleTaskCaches(ctx, s.cache, actor.TenantID, nil)
|
||||
return &DesktopAccountDeleteResult{
|
||||
Account: view,
|
||||
CancelledQueuedPublishTasks: cancelled,
|
||||
|
||||
Reference in New Issue
Block a user