groupshare

package
v0.1.4994 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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.

View Source
var ErrOff = errors.New("sharing is off here")

ErrOff is sharing with no site to share on (a test that named none).

View Source
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

func Imported(gid string, page Page) error

Imported records that group gid here was imported from page, for Updates to tell the user of the author's newer versions.

func Like

func Like(ctx context.Context, install, id string, on bool) (int, error)

Like likes shared group id, or unlikes it, from install (this computer's random id, stats.InstallID): its likes after.

func Liked

func Liked() []string

Liked are the shared groups liked here.

func LinkID

func LinkID(text string) string

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 PassOver

func PassOver(gid string, version int) error

PassOver has the user not told of version of group gid's source again.

func Report

func Report(ctx context.Context, install string) error

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

func Shared() map[string]Mine

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 Sources

func Sources() map[string]From

Sources are the shared groups the groups here came from, by id here.

func Unpublish

func Unpublish(ctx context.Context, gid string) error

Unpublish takes group gid's shared link down; one not shared, or taken down already, is done.

func Updates

func Updates(ctx context.Context) (map[string]Update, error)

Updates are the groups here whose source has a version newer than the one imported, and than the one the user passed over, by id here.

func ValidID

func ValidID(id string) bool

ValidID reports whether id is a shared group's id on usemagpie.ai.

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 Gallery struct {
	Groups []Card `json:"groups"`
	More   bool   `json:"more,omitempty"`
}

Gallery is a page of the groups shared publicly.

func List

func List(ctx context.Context, sort, q string, page int) (Gallery, error)

List is a page of the gallery: sort "top" or "new", q what the user searches for.

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.

func Publish

func Publish(ctx context.Context, gid string, meta Meta) (Mine, error)

Publish shares group gid on usemagpie.ai as provider.PublicGroup has it, with meta: at a new link, or, shared already, at its link, as its next version.

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.

func Fetch

func Fetch(ctx context.Context, id string) (Page, error)

Fetch is shared group id.

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(link string) (Retired, bool)

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.

type Update

type Update struct {
	ID      string `json:"id"`
	Version int    `json:"version"`
	Title   string `json:"title,omitempty"`
}

Update is a newer version of the shared group a group here came from.

Jump to

Keyboard shortcuts

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