bookmarks

package
v0.0.0-...-2cccd0f Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const StoreBookmarksKey = "bookmarks"

StoreBookmarksKey is the key used to store bookmarks in the plugin KV store

View Source
const StoreLabelsKey = "labels"

StoreLabelsKey is the key used to store labels in the plugin KV store

Variables

This section is empty.

Functions

func GetBookmarksKey

func GetBookmarksKey(userID string) string

func GetCodeBlockedLabels

func GetCodeBlockedLabels(names []string) string

GetCodeBlockedLabels returns a list of individually codeblocked names

func GetLabelsKey

func GetLabelsKey(userID string) string

Types

type Bookmark

type Bookmark struct {
	PostID     string   `json:"postid"`              // PostID is the ID for the bookmarked post and doubles as the Bookmark ID
	Title      string   `json:"title,omitempty"`     // Title given to the bookmark
	CreateAt   int64    `json:"create_at"`           // The original creation time of the bookmark
	ModifiedAt int64    `json:"update_at"`           // The original creation time of the bookmark
	LabelIDs   []string `json:"label_ids,omitempty"` // Array of labels added to the bookmark
}

Bookmark contains information about an individual bookmark

func (*Bookmark) AddLabelIDs

func (bm *Bookmark) AddLabelIDs(ids []string)

func (*Bookmark) GetLabelIDs

func (bm *Bookmark) GetLabelIDs() []string

func (*Bookmark) GetTitle

func (bm *Bookmark) GetTitle() string

func (*Bookmark) HasUserTitle

func (bm *Bookmark) HasUserTitle() bool

func (*Bookmark) SetTitle

func (bm *Bookmark) SetTitle(title string)

type Bookmarks

type Bookmarks struct {
	ByID map[string]*Bookmark
	// contains filtered or unexported fields
}

Bookmarks contains a map of bookmarks

func FromJSON

func FromJSON(bytes []byte) (*Bookmarks, error)

FromJSON returns unmarshalled bookmark or initialized bookmarks if bytes are empty

func NewBookmarks

func NewBookmarks(userID string) *Bookmarks

func NewBookmarksWithUser

func NewBookmarksWithUser(api pluginapi.API, userID string) (*Bookmarks, error)

NewBookmarksWithUser returns an initialized Bookmarks for a User

func (*Bookmarks) AddBookmark

func (b *Bookmarks) AddBookmark(bmark *Bookmark) error

addBookmark stores the bookmark in a map,

func (*Bookmarks) ApplyFilters

func (b *Bookmarks) ApplyFilters(filters *Filters) (*Bookmarks, error)

ApplyFilters will apply the available filters to an object of bookmarks

func (*Bookmarks) ByPostCreateAt

func (b *Bookmarks) ByPostCreateAt() ([]*Bookmark, error)

ByPostCreateAt returns an array of bookmarks sorted by post.CreateAt times

func (*Bookmarks) DeleteBookmark

func (b *Bookmarks) DeleteBookmark(bmarkID string) error

DeleteBookmark deletes a bookmark from the store

func (*Bookmarks) DeleteLabel

func (b *Bookmarks) DeleteLabel(bmarkID string, labelID string) error

DeleteLabel deletes a label from a bookmark

func (*Bookmarks) GetBmarkLabelNames

func (b *Bookmarks) GetBmarkLabelNames(bmark *Bookmark) ([]string, error)

GetBmarkLabelNames returns an array of labelNames for a given bookmark

func (*Bookmarks) GetBmarkTextDetailed

func (b *Bookmarks) GetBmarkTextDetailed(bmark *Bookmark, labelNames []string, args *model.CommandArgs) (string, error)

GetBmarkTextDetailed returns detailed, multi-line bookmark text used for an ephemeral post

func (*Bookmarks) GetBmarkTextOneLine

func (b *Bookmarks) GetBmarkTextOneLine(bmark *Bookmark, labelNames []string) (string, error)

GetBmarkTextOneLine returns a single line bookmark text used for an ephemeral post

func (*Bookmarks) GetBmarksEphemeralText

func (b *Bookmarks) GetBmarksEphemeralText(userID string, filters *Filters) (string, error)

getBmarksEphemeralText returns a the text for posting all bookmarks in an ephemeral message

func (*Bookmarks) GetBookmark

func (b *Bookmarks) GetBookmark(bmarkID string) (*Bookmark, error)

getBookmark returns a bookmark with the specified bookmarkID

func (*Bookmarks) GetBookmarksWithLabelID

func (b *Bookmarks) GetBookmarksWithLabelID(id string) (*Bookmarks, error)

func (b *Bookmarks) GetBookmarksWithLabelID(labelID string) (IBookmarks, error) {

func (*Bookmarks) StoreBookmarks

func (b *Bookmarks) StoreBookmarks() error

storeBookmarks stores all the users bookmarks

type Filters

type Filters struct {
	TitleText  string
	LabelIDs   []string
	LabelNames []string
}

type IBookmarks

type IBookmarks interface {
	GetBookmark(bmarkID string) (*Bookmark, error)
	AddBookmark(bmark *Bookmark) error
	DeleteBookmark(bmarkID string) error
	DeleteLabel(bmarkID string, labelID string) error
	GetBookmarksWithLabelID(labelID string) (*Bookmarks, error)
	GetBmarkTextOneLine(bmark *Bookmark, labelNames []string) (string, error)
	ApplyFilters(filters *Filters) (*Bookmarks, error)
	ByPostCreateAt() ([]*Bookmark, error)
	GetBmarkLabelNames(bmark *Bookmark) ([]string, error)
}

type Label

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

Label defines the parameters of a label

type Labels

type Labels struct {
	ByID map[string]*Label
	// contains filtered or unexported fields
}

Labels contains a map of labels with the label name as the key

func LabelsFromJSON

func LabelsFromJSON(bytes []byte) (*Labels, error)

LabelsFromJSON returns unmarshalled bookmark or initialized bookmarks if bytes are empty

func NewLabels

func NewLabels(userID string) *Labels

NewLabels returns an initialized Labels struct

func NewLabelsWithUser

func NewLabelsWithUser(api pluginapi.API, userID string) (*Labels, error)

NewLabelsWithUser returns an initialized Labels for a User

func (*Labels) AddLabel

func (l *Labels) AddLabel(labelName string) (*Label, error)

addLabel stores a label into the users label store

func (*Labels) DeleteByID

func (l *Labels) DeleteByID(id string) error

DeleteByID deletes a label from the store

func (*Labels) GetIDFromName

func (l *Labels) GetIDFromName(name string) (string, error)

GetIDFromName returns a label name with the corresponding label ID

func (*Labels) GetLabelByName

func (l *Labels) GetLabelByName(name string) *Label

GetLabelByName returns a label with the provided label name

func (*Labels) GetNameFromID

func (l *Labels) GetNameFromID(id string) (string, error)

GetNameFromID returns the Name of a Label

func (*Labels) StoreLabels

func (l *Labels) StoreLabels() error

storeLabels stores all the users labels

Directories

Path Synopsis
Package mock_bookmarks is a generated GoMock package.
Package mock_bookmarks is a generated GoMock package.

Jump to

Keyboard shortcuts

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