2022-10-23 06:20:48 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Monitor struct {
|
|
|
|
ID string
|
|
|
|
TribeID int64
|
|
|
|
GroupID string
|
|
|
|
CreatedAt time.Time
|
|
|
|
}
|
|
|
|
|
2022-10-27 13:18:58 +00:00
|
|
|
type MonitorWithTribe struct {
|
|
|
|
Monitor
|
2023-07-03 06:23:32 +00:00
|
|
|
Tribe Tribe
|
2022-10-27 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2022-10-23 06:20:48 +00:00
|
|
|
type MonitorAlreadyExistsError struct {
|
|
|
|
TribeID int64
|
|
|
|
GroupID string
|
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
var _ TranslatableError = MonitorAlreadyExistsError{}
|
|
|
|
|
2022-10-23 06:20:48 +00:00
|
|
|
func (e MonitorAlreadyExistsError) Error() string {
|
2023-06-18 06:47:51 +00:00
|
|
|
return fmt.Sprintf("monitor (groupID=%s,tribeID=%d) already exists", e.GroupID, e.TribeID)
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e MonitorAlreadyExistsError) Slug() string {
|
|
|
|
return "monitor-already-exists"
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e MonitorAlreadyExistsError) Params() map[string]any {
|
|
|
|
return map[string]any{
|
|
|
|
"TribeID": e.TribeID,
|
|
|
|
"GroupID": e.GroupID,
|
|
|
|
}
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MonitorLimitReachedError struct {
|
|
|
|
Current int // current number of groups
|
2023-06-27 12:00:35 +00:00
|
|
|
Limit int // max number of groups
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
var _ TranslatableError = MonitorLimitReachedError{}
|
|
|
|
|
2022-10-23 06:20:48 +00:00
|
|
|
func (e MonitorLimitReachedError) Error() string {
|
|
|
|
return fmt.Sprintf("monitor limit has been reached (%d/%d)", e.Current, e.Limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e MonitorLimitReachedError) UserError() string {
|
|
|
|
return e.Error()
|
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e MonitorLimitReachedError) Slug() string {
|
|
|
|
return "monitor-limit-reached"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e MonitorLimitReachedError) Params() map[string]any {
|
|
|
|
return map[string]any{
|
|
|
|
"Current": e.Current,
|
|
|
|
"Limit": e.Limit,
|
|
|
|
}
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
2022-10-23 07:44:20 +00:00
|
|
|
|
|
|
|
type MonitorNotFoundError struct {
|
|
|
|
ID string
|
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
var _ TranslatableError = MonitorNotFoundError{}
|
|
|
|
|
2022-10-23 07:44:20 +00:00
|
|
|
func (e MonitorNotFoundError) Error() string {
|
2023-06-18 06:47:51 +00:00
|
|
|
return fmt.Sprintf("monitor (id=%s) not found", e.ID)
|
2022-10-23 07:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e MonitorNotFoundError) UserError() string {
|
|
|
|
return e.Error()
|
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e MonitorNotFoundError) Slug() string {
|
|
|
|
return "monitor-not-found"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e MonitorNotFoundError) Params() map[string]any {
|
|
|
|
return map[string]any{
|
|
|
|
"ID": e.ID,
|
|
|
|
}
|
2022-10-23 07:44:20 +00:00
|
|
|
}
|