notifications

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 10 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"`
}

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"`

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

func (Notification) Debug added in v0.2.0

func (n Notification) Debug() string

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 | | --- | --- | --- | --- | | Exist | (1)Insert | (2)Update | (2)Update | | Missing | (3)Keep | (3)Keep | (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.

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

func (Notifications) Compact added in v0.1.0

func (n Notifications) Compact() Notifications

TODO: in-place update

func (Notifications) FilterFromIds

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

func (Notifications) IDList added in v0.0.3

func (n Notifications) IDList() []string

func (Notifications) Map added in v0.1.5

func (Notifications) Marshall added in v0.1.0

func (n Notifications) Marshall() (interface{}, error)

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) Table added in v0.2.0

func (n Notifications) Table() (string, error)

func (Notifications) Uniq added in v0.0.3

func (n Notifications) Uniq() 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"`

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

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