52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
|
|
package usecase
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
type PolicySummary struct {
|
||
|
|
AccountID string
|
||
|
|
Enabled bool
|
||
|
|
MaxDailyPosts int
|
||
|
|
MinIntervalMinutes int
|
||
|
|
ConsecutiveFailurePauseLimit int
|
||
|
|
Paused bool
|
||
|
|
PausedReason string
|
||
|
|
UpdateAt int64
|
||
|
|
}
|
||
|
|
|
||
|
|
type UpsertRequest struct {
|
||
|
|
TenantID string
|
||
|
|
OwnerUID string
|
||
|
|
AccountID string
|
||
|
|
Enabled bool
|
||
|
|
MaxDailyPosts int
|
||
|
|
MinIntervalMinutes int
|
||
|
|
ConsecutiveFailurePauseLimit int
|
||
|
|
Paused *bool
|
||
|
|
PausedReason string
|
||
|
|
}
|
||
|
|
|
||
|
|
type CheckRequest struct {
|
||
|
|
TenantID string
|
||
|
|
OwnerUID string
|
||
|
|
AccountID string
|
||
|
|
Now int64
|
||
|
|
PublishedToday int64
|
||
|
|
LastPublishedAt int64
|
||
|
|
FailureStreak int
|
||
|
|
}
|
||
|
|
|
||
|
|
type CheckResult struct {
|
||
|
|
Allowed bool
|
||
|
|
DelayUntil int64
|
||
|
|
Reason string
|
||
|
|
ShouldPause bool
|
||
|
|
}
|
||
|
|
|
||
|
|
type UseCase interface {
|
||
|
|
Get(ctx context.Context, tenantID, ownerUID, accountID string) (*PolicySummary, error)
|
||
|
|
Upsert(ctx context.Context, req UpsertRequest) (*PolicySummary, error)
|
||
|
|
Resume(ctx context.Context, tenantID, ownerUID, accountID string) (*PolicySummary, error)
|
||
|
|
Check(ctx context.Context, req CheckRequest) (*CheckResult, error)
|
||
|
|
Pause(ctx context.Context, tenantID, ownerUID, accountID, reason string) (*PolicySummary, error)
|
||
|
|
}
|