profile

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package profile defines a qri peer profile

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("profile: not found")

ErrNotFound is the not found err for the profile package

Functions

This section is empty.

Types

type ID added in v0.3.0

type ID peer.ID

ID is a distinct thing form a peer.ID. They are *NOT* meant to be interchangable but the mechanics of peer.ID & profile.ID are exactly the same

func IDB58Decode added in v0.3.0

func IDB58Decode(proid string) (ID, error)

IDB58Decode proxies a lower level API b/c I'm lazy & don't like

func IDB58MustDecode added in v0.3.0

func IDB58MustDecode(proid string) ID

IDB58MustDecode panics if an ID doesn't decode. useful for testing

func NewB58ID added in v0.3.0

func NewB58ID(pid string) (ID, error)

NewB58ID creates a peer.ID from a base58-encoded string

func (ID) MarshalJSON added in v0.3.0

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ID

func (*ID) MarshalYAML added in v0.3.0

func (id *ID) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for ID

func (ID) String added in v0.3.0

func (id ID) String() string

String implements the stringer interface for ID

func (*ID) UnmarshalJSON added in v0.3.0

func (id *ID) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface for ID

func (*ID) UnmarshalYAML added in v0.3.0

func (id *ID) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML implements the yaml.Unmarshaler interface for ID

type MemStore added in v0.3.0

type MemStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MemStore is an in-memory implementation of the profile Store interface

func (*MemStore) DeleteProfile added in v0.3.0

func (m *MemStore) DeleteProfile(id ID) error

DeleteProfile removes a peer from this store

func (*MemStore) GetProfile added in v0.3.0

func (m *MemStore) GetProfile(id ID) (*Profile, error)

GetProfile give's peer info from the store for a given peer.ID

func (*MemStore) List added in v0.3.0

func (m *MemStore) List() (map[ID]*Profile, error)

List hands the full list of peers back

func (*MemStore) PeerIDs added in v0.3.0

func (m *MemStore) PeerIDs(id ID) ([]peer.ID, error)

PeerIDs gives the peer.IDs list for a given peername

func (*MemStore) PeerProfile added in v0.3.0

func (m *MemStore) PeerProfile(id peer.ID) (*Profile, error)

PeerProfile returns profile data for a given peer.ID TODO - this func implies that peer.ID's are only ever connected to the same profile. That could cause trouble.

func (*MemStore) PeernameID added in v0.3.0

func (m *MemStore) PeernameID(peername string) (ID, error)

PeernameID gives the ID for a given peername

func (*MemStore) PutProfile added in v0.3.0

func (m *MemStore) PutProfile(profile *Profile) error

PutProfile adds a peer to this store

type Profile

type Profile struct {
	ID ID `json:"id"`
	// Created timestamp
	Created time.Time `json:"created,omitempty"`
	// Updated timestamp
	Updated time.Time `json:"updated,omitempty"`
	// PrivKey is the peer's private key, should only be present for the current peer
	PrivKey crypto.PrivKey `json:"_,omitempty"`
	// Peername a handle for the user. min 1 character, max 80. composed of [_,-,a-z,A-Z,1-9]
	Peername string `json:"peername"`
	// specifies weather this is a user or an organization
	Type Type `json:"type"`
	// user's email address
	Email string `json:"email"`
	// user name field. could be first[space]last, but not strictly enforced
	Name string `json:"name"`
	// user-filled description of self
	Description string `json:"description"`
	// url this user wants the world to click
	HomeURL string `json:"homeUrl"`
	// color this user likes to use as their theme color
	Color string `json:"color"`
	// Thumb path for user's thumbnail
	Thumb string `json:"thumb"`
	// Profile photo
	Photo string `json:"photo"`
	// Poster photo for users's profile page
	Poster string `json:"poster"`
	// Twitter is a  peer's twitter handle
	Twitter string `json:"twitter"`
	// Online indicates if this peer is currently connected to the network
	Online bool `json:"online,omitempty"`
	// PeerIDs lists any network PeerIDs associated with this profile
	// in the form /network/peerID
	PeerIDs []peer.ID `json:"peerIDs"`
	// NetworkAddrs keeps a list of locations for this profile on the network as multiaddr strings
	NetworkAddrs []ma.Multiaddr `json:"networkAddrs,omitempty"`
}

Profile defines peer profile details

func NewProfile added in v0.3.1

func NewProfile(p *config.ProfilePod) (pro *Profile, err error)

NewProfile allocates a profile from a CodingProfile

func (*Profile) Decode added in v0.3.1

func (p *Profile) Decode(sp *config.ProfilePod) error

Decode turns a ProfilePod into a profile.Profile

func (Profile) Encode added in v0.3.1

func (p Profile) Encode() (*config.ProfilePod, error)

Encode returns a ProfilePod for a given profile

type Store added in v0.3.0

type Store interface {
	List() (map[ID]*Profile, error)
	PeerIDs(id ID) ([]peer.ID, error)
	PeernameID(peername string) (ID, error)
	PutProfile(profile *Profile) error
	GetProfile(id ID) (*Profile, error)
	PeerProfile(id peer.ID) (*Profile, error)
	DeleteProfile(id ID) error
}

Store is a store of profile information

func NewMemStore added in v0.3.1

func NewMemStore() Store

NewMemStore allocates a MemStore

type Type added in v0.3.0

type Type int

Type enumerates different types of peers

const (
	// TypePeer is a single person
	TypePeer Type = iota
	// TypeOrganization represents a group of people
	TypeOrganization
)

func ParseType added in v0.3.0

func ParseType(t string) (Type, error)

ParseType decodes a peer type from a string

func (Type) MarshalJSON added in v0.3.0

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Type

func (Type) String added in v0.3.0

func (t Type) String() string

String implements the Stringer interface for Type

func (*Type) UnmarshalJSON added in v0.3.0

func (t *Type) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface for Type

Jump to

Keyboard shortcuts

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