notifications

package
v0.6.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	// Hide the notification from the user
	Hidden bool `json:"hidden"`

	// Mark the notification as done, will be deleted as soon as it's missing
	// from the remote notification list.
	Done bool `json:"done"`

	// RemoteExists is used to track if the notification is still present in the
	// remote list (i.e. the API).
	RemoteExists bool `json:"remote_exists"`

	// Tags is a list of tags that can be used to filter notifications.
	// They can be added/removed with the `tag` action.
	Tags []string `json:"tags"`
}

type Notification

type Notification struct {
	// Standard API fields
	ID         string     `json:"id"`
	Unread     bool       `json:"unread"`
	Reason     string     `json:"reason"`
	UpdatedAt  time.Time  `json:"updated_at"`
	URL        string     `json:"url"`
	Repository Repository `json:"repository"`
	Subject    Subject    `json:"subject"`

	// Enriched API fields
	Author          User   `json:"author"`
	LatestCommentor User   `json:"latest_commentor"`
	Assignees       []User `json:"assignees"`
	Reviewers       []User `json:"requested_reviewers"`
	ReviewersTeams  []Team `json:"requested_teams"`
	MergedBy        User   `json:"merged_by"`

	// gh-not specific fields
	// Those fields are not part of the GitHub API and will persist between
	// syncs.
	Meta Meta `json:"meta"`
	// contains filtered or unexported fields
}

func (Notification) Debug added in v0.2.0

func (n Notification) Debug() string

func (Notification) Equal added in v0.4.6

func (n Notification) Equal(other *Notification) bool

func (Notification) Interface added in v0.6.5

func (n Notification) Interface() (any, error)

func (Notification) Marshal added in v0.6.5

func (n Notification) Marshal() ([]byte, error)

func (Notification) String added in v0.2.0

func (n Notification) String() string

func (Notification) Visible added in v0.2.0

func (n Notification) Visible() bool

type NotificationMap

type NotificationMap map[string]*Notification

func (NotificationMap) List added in v0.1.5

func (m NotificationMap) List() Notifications

type Notifications

type Notifications []*Notification

func Sync added in v0.1.5

func Sync(local, remote Notifications) Notifications

Sync merges the local and remote notifications.

It applies the following rules:

| remote \ local | Missing    | Exist      | Done       | Hidden   |
| ---            | ---        | ---        | ---        | ---      |
| Exist          | (1) Insert | (2) Update | (2) Update | (3) Keep |
| Missing        |            | (3) Keep   | (4) Drop   | (4) Drop |

(1) Insert: Add the notification ass is.
(2) Update: Update the local notification with the remote data, keep the Meta
    unchanged.
(3) Keep: Keep the local notification unchanged.
(4) Drop: Remove the notification from the local list.

Notes on (2) Update: Updating the notification will also reset the `Meta.Done` state if the remote notification is newer than the local one.

TODO: refactor this to `func (n Notifications) Sync(remote Notifications) {}`.

it all here.

func (Notifications) Compact added in v0.1.0

func (n Notifications) Compact() Notifications

Compact remove all nil notifications. TODO: in-place update.

func (Notifications) Debug added in v0.4.6

func (n Notifications) Debug() string

func (Notifications) Equal added in v0.4.6

func (n Notifications) Equal(others Notifications) bool

func (Notifications) FilterFromIDs added in v0.5.8

func (n Notifications) FilterFromIDs(ids []string) Notifications

func (Notifications) IDList added in v0.0.3

func (n Notifications) IDList() []string

func (Notifications) Interface added in v0.3.4

func (n Notifications) Interface() (any, error)

func (Notifications) Map added in v0.1.5

func (Notifications) Marshal added in v0.3.4

func (n Notifications) Marshal() ([]byte, error)

func (Notifications) Render added in v0.4.0

func (n Notifications) Render() error

Render the notifications in a human readable format. If possible, render a table, otherwise render a simple string.

func (Notifications) Sort added in v0.1.5

func (n Notifications) Sort()

func (Notifications) String added in v0.2.0

func (n Notifications) String() string

func (Notifications) TagsMap added in v0.5.4

func (n Notifications) TagsMap() map[string]int

func (Notifications) Uniq added in v0.0.3

func (n Notifications) Uniq() Notifications

Uniq remove all duplicated notifications. TODO: in-place update.

func (Notifications) Visible added in v0.2.0

func (n Notifications) Visible() Notifications

type Repository

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	Private  bool   `json:"private"`
	Fork     bool   `json:"fork"`

	Owner User `json:"owner"`
}

type Subject

type Subject struct {
	// Standard API fields
	Title            string `json:"title"`
	URL              string `json:"url"`
	Type             string `json:"type"`
	LatestCommentURL string `json:"latest_comment_url"`

	// Enriched API fields
	State   string `json:"state"`
	HTMLURL string `json:"html_url"`
}

type Team added in v0.5.7

type Team struct {
	Name string `json:"name"`
	ID   uint   `json:"id"`
}

type User

type User struct {
	Login string `json:"login"`
	Type  string `json:"type"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL