Documentation
¶
Overview ¶
Package groupshare shares routing groups on usemagpie.ai (site/groups.js; docs/subsystems/gateway-routing.md, "Sharing a group"): a link anyone can open, a gallery of the groups shared there publicly, and, for a group imported from a link, the author's newer version when there is one.
What goes out is provider.PublicGroup: no key, account, folder or name of a provider the user added; the user sees it before it goes. The user shares, never an agent, and nothing is sent by itself but the ids of the shared groups imported here (Report, with the usage stats).
shared-groups.json, in magpie's folder and readable by the user alone, keeps the link of each group the user shared and the token that updates it or takes it down (usemagpie.ai keeps the token only hashed), and the link each imported group came from.
Index ¶
- Variables
- func Imported(gid string, page Page) error
- func Like(ctx context.Context, install, id string, on bool) (int, error)
- func Liked() []string
- func LinkID(text string) string
- func PassOver(gid string, version int) error
- func Report(ctx context.Context, install string) error
- func Shared() map[string]Mine
- func Sources() map[string]From
- func Unpublish(ctx context.Context, gid string) error
- func Updates(ctx context.Context) (map[string]Update, error)
- func ValidID(id string) bool
- type Card
- type From
- type Gallery
- type Meta
- type Mine
- type Page
- type Retired
- type Update
Constants ¶
This section is empty.
Variables ¶
var ErrGone = errors.New("this shared group was taken down on usemagpie.ai")
ErrGone is a shared group usemagpie.ai doesn't have: taken down by its author, or on a report.
var ErrOff = errors.New("sharing is off here")
ErrOff is sharing with no site to share on (a test that named none).
var Site = func() string { if s := os.Getenv("MAGPIE_SHARE_SITE"); s != "" { return strings.TrimRight(s, "/") } if testing.Testing() { return "" } return "https://usemagpie.ai" }
Site is where groups are shared. MAGPIE_SHARE_SITE moves it, as it moves shared artifacts, and a test names its own: a test never reaches the real site.
Functions ¶
func Imported ¶
Imported records that group gid here was imported from page, for Updates to tell the user of the author's newer versions.
func Like ¶
Like likes shared group id, or unlikes it, from install (this computer's random id, stats.InstallID): its likes after.
func LinkID ¶
LinkID is the shared group's id in text: a link to its page (https://usemagpie.ai/g/<id>), a magpie://group?id=<id> link, or the id alone; "" for anything else, a group shared as text included.
func Report ¶
Report tells usemagpie.ai the shared groups imported here that are still here, from install, for the gallery's counts: with the usage stats, and never when the user turned those off.
func Shared ¶
Shared is each group the user shared, by its id here, with no token: what the GUI shows. Groups no longer here are left out.
func Unpublish ¶
Unpublish takes group gid's shared link down; one not shared, or taken down already, is done.
Types ¶
type Card ¶
type Card struct {
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
Version int `json:"version"`
Updated int64 `json:"updated,omitempty"`
Members []string `json:"members"`
Routing string `json:"routing,omitempty"`
Rules int `json:"rules,omitempty"`
Uses int `json:"uses,omitempty"`
Likes int `json:"likes,omitempty"`
// Here is how many of its members this magpie has (provider.MembersHere)
Here int `json:"here"`
// Mine: one the user shared; Imported: the id of the group here
// imported from it
Mine bool `json:"mine,omitempty"`
Imported string `json:"imported,omitempty"`
Liked bool `json:"liked,omitempty"`
}
Card is a group in the gallery.
type From ¶
type From struct {
ID string `json:"id"`
Version int `json:"version"`
Title string `json:"title,omitempty"`
At time.Time `json:"at"`
// Seen is the newest version the user was told of and passed over:
// not offered again
Seen int `json:"seen,omitempty"`
}
From is the shared group a group here was imported from.
type Meta ¶
type Meta struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
// Public lists it in the gallery; unlisted, only its link opens it
Public bool `json:"public"`
}
Meta is what the user says of a group they share.
type Mine ¶
type Mine struct {
Meta
ID string `json:"id"` // on usemagpie.ai
URL string `json:"url"`
Token string `json:"token,omitempty"`
Version int `json:"version"`
At time.Time `json:"at"`
}
Mine is a group the user shared, by its id here.
type Page ¶
type Page struct {
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
Public bool `json:"public"`
Version int `json:"version"`
Updated int64 `json:"updated,omitempty"`
Group provider.SharedGroup `json:"group,omitzero"`
Uses int `json:"uses,omitempty"`
Likes int `json:"likes,omitempty"`
}
Page is a shared group as usemagpie.ai has it.
type Retired ¶
type Retired struct {
Mine
Group string `json:"group"` // its id here, when it was removed
Gone time.Time `json:"gone"`
}
Retired is a link a group shared before it was removed: kept, with its token, so it is never lost; a group made later under the same id shares at a link of its own (#7883). The link stays up as it was.
func RetiredLink ¶
RetiredLink is the link a removed group was shared at, by the link or its id (LinkID): still up, and taken down by Unpublish with it.