Documentation
¶
Index ¶
- Constants
- type APubHandler
- type Database
- type InfoFinder
- type Post
- func (p *Post) FeedURL() string
- func (p *Post) HTML() string
- func (p *Post) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (p *Post) Mentions() []string
- func (p *Post) PostURL() string
- func (p *Post) PostedAt() time.Time
- func (p *Post) Text() string
- func (p *Post) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type RecipInfo
- type User
- type UserInfo
- func (info *UserInfo) AtomFeedURL() string
- func (info *UserInfo) InboxURL() string
- func (info *UserInfo) LastUpdated() time.Time
- func (info *UserInfo) LoadPrivateKey(pemStr string) (err error)
- func (info *UserInfo) MarshalJSON() ([]byte, error)
- func (info *UserInfo) OutboxURL() string
- func (info *UserInfo) Posts(offset int64, limit int) (posts []apub.Post, err error)
- func (info *UserInfo) ProfileURL() string
- func (info *UserInfo) RegenerateSigningKey() (err error)
- func (info *UserInfo) Sign(r io.Reader) (sig, hash []byte, err error)
- func (info *UserInfo) ToAtomFeed(title string, nextURL string) (f apub.UserFeed, err error)
- func (info *UserInfo) User() string
- func (info *UserInfo) WebFingerAlias() string
- func (info *UserInfo) WebFingerLinks() (links []apub.Link)
- func (info *UserInfo) WebFingerSubject() string
- type UserName
Constants ¶
View Source
const ContentType = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
ContentType is the mimetype for activitypub
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APubHandler ¶
type APubHandler struct {
Database Database // Database must not be nil
// contains filtered or unexported fields
}
APubHandler
func (*APubHandler) SetupRoutes ¶
func (a *APubHandler) SetupRoutes(setupRoute func(string, http.Handler), setupSubRouter func(string, http.Handler))
SetupRoutes sets up routes
type Database ¶
type Database interface {
// return the local server's hostname
LocalHost() string
// LocalUser gets a local user by username
// returns user, nil on found
// returns nil, nil on not found
// returns nil, error on db error
LocalUser(username string) (User, error)
// LocalPost gets a local post by post id
// returns post, nil on post found
// returns nil, nil on post not found
// returns nil, error on db error
LocalPost(postid string) (*Post, error)
// LocalUserPosts gets a slice of posts of a user by name with offset and limit
// posts may be empty
// retruns posts, nil on success
// returns nil, err on db error
LocalUserPosts(username string, offset int64, limit int) ([]*Post, error)
ListFollowers(username string) ([]User, error)
ListFollowing(username string) ([]User, error)
}
Database defines an interface for interacting with a persistant datastore for posts and user information
type InfoFinder ¶
type InfoFinder interface {
// returns nil, nil on not found
// returns url, nil on found
// returns nil, error on error
LocalUser(string) (*UserInfo, error)
// list all users that follow a user by local username
ListFollowers(string) ([]*UserInfo, error)
// list all users that a local users follows by local username
ListFollowing(string) ([]*UserInfo, error)
}
InfoFinder finds a UserInfo given a string
type Post ¶
type Post struct {
Message string
To RecipInfo
From string
Posted time.Time
Updated time.Time
Feed string
Self string
}
func (*Post) MarshalXML ¶
func (*Post) UnmarshalXML ¶
type UserInfo ¶
type UserInfo struct {
ServerName string // server name
UserName string // username without '@'
PreferedName string // prefered name
Summary string // profile summary
Avatar string // avatar url
Header string // header url
SigningKey *rsa.PrivateKey // rsa private signing key
Profile string // profile url
Inbox string // inbox url
Outbox string // outbox url
Feed string // atom feed url
GetPosts func(offset int64, limit int) ([]*Post, error)
GetLastUpdated func() time.Time
}
local user implements apub.User
func (*UserInfo) AtomFeedURL ¶
func (*UserInfo) LastUpdated ¶
func (*UserInfo) LoadPrivateKey ¶
func (*UserInfo) MarshalJSON ¶
func (*UserInfo) ProfileURL ¶
func (*UserInfo) RegenerateSigningKey ¶
func (*UserInfo) ToAtomFeed ¶
func (*UserInfo) WebFingerAlias ¶
func (*UserInfo) WebFingerLinks ¶
func (*UserInfo) WebFingerSubject ¶
type UserName ¶
type UserName string
UserName is the @user@host
func NormalizeUser ¶
NormalizeUser converts a string into a UserName given our local server name
Click to show internal directories.
Click to hide internal directories.