Documentation ¶
Overview ¶
Package notification provides a notification service definition.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct { Action string // "opened", "closed", "merged", "reopened". ChangeTitle string ChangeBody string // Only set when action is "opened". ChangeHTMLURL string }
Change is a change event.
type ChangeComment ¶
type ChangeComment struct { ChangeTitle string ChangeState state.Change CommentBody string CommentReview state.Review CommentHTMLURL string }
ChangeComment is a change comment event. A change comment is a review iff CommentReview is non-zero.
type Issue ¶
type Issue struct { Action string // "opened", "closed", "reopened". IssueTitle string IssueBody string // Only set when action is "opened". IssueHTMLURL string }
Issue is an issue event.
type IssueComment ¶
type IssueComment struct { IssueTitle string IssueState state.Issue CommentBody string CommentHTMLURL string }
IssueComment is an issue comment event.
type ListOptions ¶
type ListOptions struct { // Namespace is an optional filter. If not empty, only notifications // from the specified namespace will be listed. Namespace string // All specifies whether to include read notifications in addition to // unread ones. All bool }
ListOptions are options for ListNotifications.
type Notification ¶
type Notification struct { Namespace string ThreadType string ThreadID uint64 ImportPaths []string // 1 or more. Time time.Time Actor users.User // Payload specifies the event type. It's one of // Issue, Change, IssueComment, or ChangeComment. Payload interface{} Unread bool Participating bool // Whether user is participating in the thread, or just watching. Mentioned bool // Whether user was specifically @mentioned in the content. }
Notification represents a notification.
func (Notification) MarshalJSON ¶
func (n Notification) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*Notification) UnmarshalJSON ¶
func (n *Notification) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type NotificationRequest ¶
type NotificationRequest struct { ImportPaths []string // 1 or more. Time time.Time // Canonical initial time of the notification request. // Payload specifies the event type. It's one of // Issue, Change, IssueComment, or ChangeComment. Payload interface{} }
NotificationRequest represents a request to create a notification.
type Service ¶
type Service interface { // ListNotifications lists notifications for authenticated user. // A permission error is returned if no authenticated user. ListNotifications(ctx context.Context, opt ListOptions) ([]Notification, error) // StreamNotifications streams notifications for authenticated user, // sending them to ch until context is canceled or an error occurs. // A permission error is returned if no authenticated user. // TODO: Consider changing signature to single Notification rather than slice, if slice isn't helpful. StreamNotifications(ctx context.Context, ch chan<- []Notification) error // CountNotifications counts unread notifications for authenticated user. // A permission error is returned if no authenticated user. CountNotifications(ctx context.Context) (uint64, error) // MarkThreadRead marks the specified notification thread as read. // A permission error is returned if no authenticated user. MarkThreadRead(ctx context.Context, namespace, threadType string, threadID uint64) error // SubscribeThread subscribes subscribers to the specified thread. // If threadType and threadID are zero, subscribers are subscribed // to watch the entire namespace. // Returns a permission error if no authenticated user. // // THINK: Why is MarkRead and MarkAllRead 2 separate methods instead of 1, // but this is combined into one method? Maybe there should be: // SubscribeAll(ctx context.Context, namespace string, subscribers []users.UserSpec) error // Or maybe MarkAllRead should be merged into MarkRead? SubscribeThread(ctx context.Context, namespace, threadType string, threadID uint64, subscribers []users.UserSpec) error // NotifyThread notifies subscribers of the specified thread of a notification. // The authenticated user will be the notification actor. // Returns a permission error if no authenticated user. NotifyThread(ctx context.Context, namespace, threadType string, threadID uint64, nr NotificationRequest) error }
Service defines methods of a notification service.
Directories ¶
Path | Synopsis |
---|---|
Package fs implements notification.Service using a virtual filesystem.
|
Package fs implements notification.Service using a virtual filesystem. |
Package httpclient contains notification.Service implementation over HTTP.
|
Package httpclient contains notification.Service implementation over HTTP. |
Package httphandler contains an API handler for notification.Service.
|
Package httphandler contains an API handler for notification.Service. |
Package httproute contains route paths for httpclient, httphandler.
|
Package httproute contains route paths for httpclient, httphandler. |
Package v2tov1 provides a notifv1.Service wrapper on top of a notifv2.Service implementation.
|
Package v2tov1 provides a notifv1.Service wrapper on top of a notifv2.Service implementation. |
Click to show internal directories.
Click to hide internal directories.