notifications: github.com/shurcooL/notifications Index | Files | Directories

package notifications

import "github.com/shurcooL/notifications"

Package notifications provides a notifications service definition.

Index

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(ctx context.Context, appID string, repo RepoSpec, threadID uint64, subscribers []users.UserSpec) error

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

    Notify(ctx context.Context, appID string, repo RepoSpec, 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
}

ListOptions are options for List operation.

type Notification Uses

type Notification struct {
    AppID     string // TODO: Rename AppID to "ThreadType" and shuffle its order to make it more clear: (RepoURI, ThreadType, ThreadID).
    RepoSpec  RepoSpec
    ThreadID  uint64
    RepoURL   string
    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
    HTMLURL   string // Address of notification target.

    Participating bool // Whether user is participating in the thread, or just watching.
}

Notification represents a notification.

type NotificationRequest Uses

type NotificationRequest struct {
    Title     string
    Icon      OcticonID
    Color     RGB
    Actor     users.UserSpec // Actor that triggered the notification.
    UpdatedAt time.Time      // TODO: Maybe not needed? Why not use time.Now()?
    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., "user/repo".
}

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

    ExternalService
}

Service for notifications.

Directories

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

Package notifications imports 4 packages (graph) and is imported by 13 packages. Updated 2017-03-25. Refresh now. Tools for package owners.