1package models
2
3import (
4 "time"
5)
6
7type NotificationType string
8
9const (
10 NotificationTypeRepoStarred NotificationType = "repo_starred"
11 NotificationTypeIssueCreated NotificationType = "issue_created"
12 NotificationTypeIssueCommented NotificationType = "issue_commented"
13 NotificationTypePullCreated NotificationType = "pull_created"
14 NotificationTypePullCommented NotificationType = "pull_commented"
15 NotificationTypeFollowed NotificationType = "followed"
16 NotificationTypePullMerged NotificationType = "pull_merged"
17 NotificationTypeIssueClosed NotificationType = "issue_closed"
18 NotificationTypePullClosed NotificationType = "pull_closed"
19)
20
21type Notification struct {
22 ID int64
23 RecipientDid string
24 ActorDid string
25 Type NotificationType
26 EntityType string
27 EntityId string
28 Read bool
29 Created time.Time
30
31 // foreign key references
32 RepoId *int64
33 IssueId *int64
34 PullId *int64
35}
36
37// lucide icon that represents this notification
38func (n *Notification) Icon() string {
39 switch n.Type {
40 case NotificationTypeRepoStarred:
41 return "star"
42 case NotificationTypeIssueCreated:
43 return "circle-dot"
44 case NotificationTypeIssueCommented:
45 return "message-square"
46 case NotificationTypeIssueClosed:
47 return "ban"
48 case NotificationTypePullCreated:
49 return "git-pull-request-create"
50 case NotificationTypePullCommented:
51 return "message-square"
52 case NotificationTypePullMerged:
53 return "git-merge"
54 case NotificationTypePullClosed:
55 return "git-pull-request-closed"
56 case NotificationTypeFollowed:
57 return "user-plus"
58 default:
59 return ""
60 }
61}
62
63type NotificationWithEntity struct {
64 *Notification
65 Repo *Repo
66 Issue *Issue
67 Pull *Pull
68}
69
70type NotificationPreferences struct {
71 ID int64
72 UserDid string
73 RepoStarred bool
74 IssueCreated bool
75 IssueCommented bool
76 PullCreated bool
77 PullCommented bool
78 Followed bool
79 PullMerged bool
80 IssueClosed bool
81 EmailNotifications bool
82}