Documentation ¶
Index ¶
- Constants
- type Account
- type Activity
- type ActivityType
- type Actor
- type ActorType
- type CreateAccountHandler
- type Endpoints
- type Error
- type FediHelper
- func (f *FediHelper) FetchActor(ctx context.Context, actorIRI *url.URL) (*Actor, error)
- func (f *FediHelper) FetchHostMeta(ctx context.Context, domain string) (*HostMeta, error)
- func (f *FediHelper) FetchWebFinger(ctx context.Context, wfURI WebfingerURI, username, domain string) (*WebFinger, error)
- func (f *FediHelper) FetchWellknownWebFinger(ctx context.Context, serverHostname, username, domain string) (*WebFinger, error)
- func (f *FediHelper) GenerateFediAccountFromUsername(ctx context.Context, username string, instance Instance, account Account) error
- func (f *FediHelper) GenerateFediInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
- func (f *FediHelper) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, bool, error)
- func (f *FediHelper) GetNodeInfo20(ctx context.Context, infoURI *url.URL) (*lib.NodeInfo, error)
- func (f *FediHelper) GetOrCreateAccount(ctx context.Context, instanceAccountID, username string, instance Instance) (Account, error)
- func (f *FediHelper) GetWellknownNodeInfo(ctx context.Context, domain string) (*lib.WellKnownNodeInfo, error)
- func (f *FediHelper) Helper(s SoftwareName) (Helper, error)
- func (f *FediHelper) SetCreateAccountHandler(handler CreateAccountHandler)
- func (f *FediHelper) SetGetAccountHandler(handler GetAccountHandler)
- func (f *FediHelper) SetNewAccountHandler(handler NewAccountHandler)
- func (f *FediHelper) UpdateAccountInfo(ctx context.Context, account Account) error
- func (f *FediHelper) UpdateInstanceInfo(ctx context.Context, instance Instance) error
- func (*FediHelper) WebfingerURIFromHostMeta(hostMeta *HostMeta) (string, error)
- type GetAccountHandler
- type Helper
- type HostMeta
- type HttpClient
- type Instance
- type InstanceInfo
- type KV
- type Link
- type NewAccountHandler
- type NoHelperError
- type PublicKey
- type SoftwareName
- type Transport
- type WebFinger
- type WebfingerURI
Constants ¶
const ( // ContextActivityStreams contains the context document for activity streams. ContextActivityStreams = "https://www.w3.org/ns/activitystreams" // HostMetaWebFingerTemplateRel matches a webfinger link relationship. HostMetaWebFingerTemplateRel = "lrdd" // NodeInfo20Schema the schema url for nodeinfo 2.0. NodeInfo20Schema = "http://nodeinfo.diaspora.software/ns/schema/2.0" // SoftwareMastodon is the software keyword for Mastodon. SoftwareMastodon SoftwareName = "mastodon" // SoftwarePleroma is the software keyword for Pleroma. SoftwarePleroma SoftwareName = "pleroma" // TypeAccept is the Accept activity Type. TypeAccept ActivityType = "Accept" // TypeAdd is the Add activity Type. TypeAdd ActivityType = "Add" // TypeAnnounce is the Announce activity Type. TypeAnnounce ActivityType = "Announce" // TypeCreate is the Create activity Type. TypeCreate ActivityType = "Create" // TypeDelete is the Delete activity Type. TypeDelete ActivityType = "Delete" // TypeFollow is the Follow activity Type. TypeFollow ActivityType = "Follow" // TypeMove is the Move activity Type. TypeMove ActivityType = "Move" // TypeRemove is the Remove activity Type. TypeRemove ActivityType = "Remove" // TypeUndo is the Undo activity Type. TypeUndo ActivityType = "Undo" // TypeUpdate is the Update activity Type. TypeUpdate ActivityType = "Update" // TypeApplication is the Application actor type. TypeApplication ActorType = "Application" // TypePerson is the Person actor type. TypePerson ActorType = "Person" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { GetActorURI() (actorURI string) GetID() (id int64) GetInstance() (instance Instance) GetInstanceAccountID() (instanceAccountID string) GetLastFinger() (lastFinger time.Time) GetUsername() (username string) SetActorURI(actorURI string) SetInstance(instance Instance) SetInstanceAccountID(instanceAccountID string) SetLastFinger(lastFinger time.Time) SetUsername(username string) SetInfoAvatarURL(avatarURL string) SetInfoDisplayName(displayName string) SetInfoHeaderURL(headerURL string) SetInfoIsBot(isBot bool) SetInfoIsLocked(isLocked bool) SetInfoIsMoved(isMoved bool) SetInfoURL(url string) SetInfoLastUpdate(lastUpdate time.Time) }
type Activity ¶
type Activity map[string]interface{}
func (Activity) ObjectType ¶
func (a Activity) ObjectType() (ActivityType, error)
func (Activity) Type ¶
func (a Activity) Type() (ActivityType, error)
type ActivityType ¶
type ActivityType string
func (ActivityType) String ¶
func (a ActivityType) String() string
type Actor ¶
type Actor struct { Context interface{} `json:"@context"` Endpoints Endpoints `json:"endpoints"` Followers string `json:"followers"` Following string `json:"following"` Inbox string `json:"inbox"` Name string `json:"name"` Type ActorType `json:"type"` ID string `json:"id"` PublicKey PublicKey `json:"publicKey"` Summary string `json:"summary"` PreferredUsername string `json:"preferredUsername"` URL string `json:"url"` }
Actor is an actor response.
func (*Actor) MakeInstance ¶
type CreateAccountHandler ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a fedihelper specific error.
type FediHelper ¶
type FediHelper struct { CreateAccountHandler CreateAccountHandler GetAccountHandler GetAccountHandler NewAccountHandler NewAccountHandler // contains filtered or unexported fields }
FediHelper is a module for working with federated social instances.
func (*FediHelper) FetchActor ¶
func (*FediHelper) FetchHostMeta ¶
func (*FediHelper) FetchWebFinger ¶
func (f *FediHelper) FetchWebFinger(ctx context.Context, wfURI WebfingerURI, username, domain string) (*WebFinger, error)
FetchWebFinger retrieves web finger resource from a federated instance.
func (*FediHelper) FetchWellknownWebFinger ¶
func (f *FediHelper) FetchWellknownWebFinger(ctx context.Context, serverHostname, username, domain string) (*WebFinger, error)
FetchWellknownWebFinger retrieves wellknown web finger resource from a federated instance.
func (*FediHelper) GenerateFediAccountFromUsername ¶
func (f *FediHelper) GenerateFediAccountFromUsername(ctx context.Context, username string, instance Instance, account Account) error
GenerateFediAccountFromUsername creates an Account object by querying the apis of the federated instance.
func (*FediHelper) GenerateFediInstanceFromDomain ¶
func (f *FediHelper) GenerateFediInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
GenerateFediInstanceFromDomain created a Instance object by querying the apis of the federated instance.
func (*FediHelper) GetLoginURL ¶
func (f *FediHelper) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, bool, error)
GetLoginURL retrieves an oauth url for a federated instance, returns true if instance was updated.
func (*FediHelper) GetNodeInfo20 ¶
GetNodeInfo20 retrieves wellknown nodeinfo from a federated instance.
func (*FediHelper) GetOrCreateAccount ¶ added in v0.17.0
func (f *FediHelper) GetOrCreateAccount(ctx context.Context, instanceAccountID, username string, instance Instance) (Account, error)
GetOrCreateAccount gets an account from the database or .
func (*FediHelper) GetWellknownNodeInfo ¶
func (f *FediHelper) GetWellknownNodeInfo(ctx context.Context, domain string) (*lib.WellKnownNodeInfo, error)
GetWellknownNodeInfo retrieves wellknown nodeinfo from a federated instance.
func (*FediHelper) Helper ¶
func (f *FediHelper) Helper(s SoftwareName) (Helper, error)
Helper returns a helper for a given software package.
func (*FediHelper) SetCreateAccountHandler ¶
func (f *FediHelper) SetCreateAccountHandler(handler CreateAccountHandler)
func (*FediHelper) SetGetAccountHandler ¶
func (f *FediHelper) SetGetAccountHandler(handler GetAccountHandler)
func (*FediHelper) SetNewAccountHandler ¶
func (f *FediHelper) SetNewAccountHandler(handler NewAccountHandler)
func (*FediHelper) UpdateAccountInfo ¶ added in v0.17.0
func (f *FediHelper) UpdateAccountInfo(ctx context.Context, account Account) error
UpdateAccountInfo updates the account info.
func (*FediHelper) UpdateInstanceInfo ¶ added in v0.17.0
func (f *FediHelper) UpdateInstanceInfo(ctx context.Context, instance Instance) error
UpdateInstanceInfo updated the instance info.
func (*FediHelper) WebfingerURIFromHostMeta ¶
func (*FediHelper) WebfingerURIFromHostMeta(hostMeta *HostMeta) (string, error)
type GetAccountHandler ¶
type Helper ¶
type Helper interface { GetAccessToken(ctx context.Context, redirectURI *url.URL, instance Instance, code string) (accessToken string, err error) GetCurrentAccount(ctx context.Context, instance Instance, accessToken string) (user Account, err error) GetSoftware() SoftwareName RegisterApp(ctx context.Context, redirectURI *url.URL, instance Instance) (clientID string, clientSecret string, err error) SetFedi(f *FediHelper) MakeLoginURI(ctx context.Context, redirectURI *url.URL, instance Instance) (loginURI *url.URL, err error) UpdateAccountInfo(ctx context.Context, account Account) error UpdateInstanceInfo(ctx context.Context, instance Instance) error }
Helper interacts with a federated social instance.
type HostMeta ¶
func (*HostMeta) WebfingerURI ¶
func (h *HostMeta) WebfingerURI() WebfingerURI
type HttpClient ¶
type HttpClient interface { pub.HttpClient Transport() (transport http.RoundTripper) }
type Instance ¶
type Instance interface { GetActorURI() (actorURI string) GetOAuthClientID() (clientID string) GetOAuthClientSecret() (clientSecret string, err error) GetDomain() (domain string) GetID() (id int64) GetServerHostname() (hostname string) GetSoftware() (software string) SetActorURI(actorURI string) SetOAuthClientID(clientID string) SetOAuthClientSecret(clientSecret string) error SetDomain(domain string) SetInboxURI(inboxURI string) SetServerHostname(hostname string) SetSoftware(software string) SetInfoTitle(title string) SetInfoDescription(description string) SetContactAccount(account Account) SetVersion(version string) SetLastUpdate(lastUpdate time.Time) }
type InstanceInfo ¶ added in v0.17.0
InstanceInfo represents a instance.
type KV ¶
type KV interface { DeleteAccessToken(ctx context.Context, accountID int64) (err error) GetAccessToken(ctx context.Context, accountID int64) (accessToken string, err error) SetAccessToken(ctx context.Context, accountID int64, accessToken string) (err error) DeleteActor(ctx context.Context, actorURI string) (err error) GetActor(ctx context.Context, actorURI string) (actor []byte, err error) SetActor(ctx context.Context, actorURI string, actor []byte, expire time.Duration) (err error) DeleteHostMeta(ctx context.Context, domain string) (err error) GetHostMeta(ctx context.Context, domain string) (hostmeta []byte, err error) SetHostMeta(ctx context.Context, domain string, hostmeta []byte, expire time.Duration) (err error) DeleteFediNodeInfo(ctx context.Context, domain string) (err error) GetFediNodeInfo(ctx context.Context, domain string) (nodeinfo []byte, err error) SetFediNodeInfo(ctx context.Context, domain string, nodeinfo []byte, expire time.Duration) (err error) }
type Link ¶
type Link struct { Href string `json:"href,omitempty"` Rel string `json:"rel,omitempty" xml:"rel,attr"` Template string `json:"template,omitempty" xml:"template,attr"` Type string `json:"type,omitempty"` }
Link represents a link.
type NewAccountHandler ¶
type NoHelperError ¶ added in v0.17.0
type NoHelperError struct {
// contains filtered or unexported fields
}
NoHelperError represents a missing helper error.
func NewNoHelperError ¶ added in v0.17.0
func NewNoHelperError(software string) *NoHelperError
NewNoHelperError wraps a message in a NoHelperError object.
func (*NoHelperError) Error ¶ added in v0.17.0
func (e *NoHelperError) Error() string
Error returns the error message as a string.
type PublicKey ¶
type PublicKey struct { ID string `json:"id"` Owner string `json:"owner"` PublicKeyPEM string `json:"publicKeyPem"` }
PublicKey represents an actor's public key.
type SoftwareName ¶
type SoftwareName string
func (SoftwareName) String ¶
func (s SoftwareName) String() string
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport handled signing outgoing requests to federated instances.
func NewTransport ¶
func NewTransport(clock pub.Clock, client HttpClient, pubKeyID string, privkey crypto.PrivateKey) (*Transport, error)
NewTransport creates a new Transport module.
func (*Transport) Client ¶
func (t *Transport) Client() HttpClient
func (*Transport) InstanceGet ¶
type WebFinger ¶
type WebFinger struct { Aliases []string `json:"aliases,omitempty"` Links []Link `json:"links,omitempty"` Subject string `json:"subject,omitempty"` }
WebFinger is a web finger response.
type WebfingerURI ¶
type WebfingerURI string
func (WebfingerURI) FTemplate ¶
func (w WebfingerURI) FTemplate() string
func (WebfingerURI) String ¶
func (w WebfingerURI) String() string