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