notifications: Index | Files | Directories

package notifications

import ""

Package notifications provides a notifications service definition.


Package Files

general.go notifications.go

type CopierFrom Uses

type CopierFrom interface {
    // CopyFrom copies all accessible notifications from src to dst user.
    // ctx should provide permission to access all notifications in src.
    CopyFrom(ctx context.Context, src Service, dst users.UserSpec) error

CopierFrom is an optional interface that allows copying notifications between services.

type ExternalService Uses

type ExternalService interface {
    // Subscribe subscribes subscribers to the specified thread.
    // If threadType and threadID are zero, subscribers are subscribed
    // to watch the entire repo.
    // 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, repo RepoSpec, subscribers []users.UserSpec) error
    //        Or maybe MarkAllRead should be merged into MarkRead?
    Subscribe(ctx context.Context, repo RepoSpec, threadType string, threadID uint64, subscribers []users.UserSpec) error

    // MarkRead marks the specified thread as read.
    MarkRead(ctx context.Context, repo RepoSpec, threadType string, threadID uint64) error

    // Notify notifies subscribers of the specified thread of a notification.
    Notify(ctx context.Context, repo RepoSpec, threadType string, threadID uint64, nr NotificationRequest) error

ExternalService for notifications.

type ListOptions Uses

type ListOptions struct {
    // Repo is an optional filter. If not nil, only notifications from Repo will be listed.
    Repo *RepoSpec

    // All specifies whether to include read notifications in addition to unread ones.
    All bool

ListOptions are options for List operation.

type Notification Uses

type Notification struct {
    RepoSpec   RepoSpec
    ThreadType string
    ThreadID   uint64
    Title      string
    Icon       OcticonID // TODO: Some notifications can exist for a long time. OcticonID may change when frontend updates to newer versions of octicons. Think of a better long term solution?
    Color      RGB
    Actor      users.User
    UpdatedAt  time.Time
    Read       bool
    HTMLURL    string // Address of notification target.

    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.

type NotificationRequest Uses

type NotificationRequest struct {
    Title     string
    Icon      OcticonID
    Color     RGB
    Actor     users.UserSpec // Actor that triggered the notification. TODO: Maybe not needed? Why not use current user?
    UpdatedAt time.Time      // TODO: Maybe not needed? Why not use time.Now()? Could do it, but time.Now() will be slightly later than original request time.
    HTMLURL   string         // Address of notification target.

NotificationRequest represents a request to create a notification.

type Notifications Uses

type Notifications []Notification

Notifications implements sort.Interface.

func (Notifications) Len Uses

func (s Notifications) Len() int

func (Notifications) Less Uses

func (s Notifications) Less(i, j int) bool

func (Notifications) Swap Uses

func (s Notifications) Swap(i, j int)

type OcticonID Uses

type OcticonID string

Octicon ID. E.g., "issue-opened".

type RGB Uses

type RGB struct {
    R, G, B uint8

RGB represents a 24-bit color without alpha channel.

func (RGB) HexString Uses

func (c RGB) HexString() string

HexString returns a hexadecimal color string. For example, "#ff0000" for red.

type RepoSpec Uses

type RepoSpec struct {
    URI string // URI is clean '/'-separated URI. E.g., "".

RepoSpec is a specification for a repository.

func (RepoSpec) String Uses

func (rs RepoSpec) String() string

String implements fmt.Stringer.

type Service Uses

type Service interface {
    // List notifications for authenticated user.
    // Returns a permission error if no authenticated user.
    List(ctx context.Context, opt ListOptions) (Notifications, error)

    // Count notifications for authenticated user.
    // Returns a permission error if no authenticated user.
    Count(ctx context.Context, opt interface{}) (uint64, error)

    // MarkAllRead marks all notifications in the specified repository as read.
    MarkAllRead(ctx context.Context, repo RepoSpec) error


Service for notifications.


fsPackage fs implements notifications.Service using a virtual filesystem.
githubapiPackage githubapi implements notifications.Service using GitHub API clients.

Package notifications imports 4 packages (graph) and is imported by 21 packages. Updated 2018-02-17. Refresh now. Tools for package owners.