-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdashboard_link.go
71 lines (59 loc) · 2.58 KB
/
dashboard_link.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package malak
import (
"context"
"time"
"github.com/google/uuid"
"github.com/uptrace/bun"
)
var ErrDashboardLinkNotFound = MalakError("dashboard link not found")
// ENUM(default,contact)
type DashboardLinkType string
type DashboardLink struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4(),pk" json:"id,omitempty"`
Reference Reference `json:"reference,omitempty"`
DashboardID uuid.UUID `json:"dashboard_id,omitempty"`
Dashboard *Dashboard `json:"-" bun:"rel:has-one,join:dashboard_id=id"`
LinkType DashboardLinkType `json:"link_type,omitempty"`
Token string `json:"token,omitempty"`
ContactID uuid.UUID `json:"contact_id,omitempty" bun:",nullzero"`
Contact *Contact `json:"contact,omitempty" bun:"rel:has-one,join:contact_id=id"`
ExpiresAt *time.Time `bun:",nullzero" json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty" bun:",default:current_timestamp"`
UpdatedAt time.Time `json:"updated_at,omitempty" bun:",default:current_timestamp"`
DeletedAt *time.Time `bun:",soft_delete,nullzero" json:"-,omitempty"`
bun.BaseModel `json:"-"`
}
// type DashboardLinkAccessLog struct {
// ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4(),pk" json:"id,omitempty"`
// Reference Reference `json:"reference,omitempty"`
// DashboardLinkID uuid.UUID `json:"dashboard_link_id,omitempty"`
// ContactID uuid.UUID `json:"contact_id,omitempty" bun:",nullzero"`
// Contact *Contact `json:"contact,omitempty" bun:"rel:has-one,join:contact_id=id"`
//
// IPAddress string `json:"ip_address,omitempty"`
// Device string `json:"device,omitempty"`
//
// CreatedAt time.Time `json:"created_at,omitempty" bun:",default:current_timestamp"`
// UpdatedAt time.Time `json:"updated_at,omitempty" bun:",default:current_timestamp"`
// DeletedAt *time.Time `bun:",soft_delete,nullzero" json:"-,omitempty"`
//
// bun.BaseModel `json:"-"`
// }
type CreateDashboardLinkOptions struct {
Link *DashboardLink
Email Email
WorkspaceID uuid.UUID
Generator ReferenceGeneratorOperation
UserID uuid.UUID
}
type ListAccessControlOptions struct {
Paginator Paginator
DashboardID uuid.UUID
}
type DashboardLinkRepository interface {
Create(context.Context, *CreateDashboardLinkOptions) error
DefaultLink(context.Context, *Dashboard) (DashboardLink, error)
PublicDetails(context.Context, Reference) (Dashboard, error)
List(context.Context, ListAccessControlOptions) ([]DashboardLink, int64, error)
Delete(context.Context, Dashboard, Reference) error
}