Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidFeedType(t FeedType) bool
- func NormalizeUsername(username string) string
- func SetTwtManager(m TwtManager)
- func SplitTwts(twts Twts, ttl time.Duration, N int) (Twts, Twts, Twts)
- type ArchivedFeed
- type AuthRequest
- type AuthResponse
- type ConversationRequest
- type ErrDeadFeed
- type ExternalProfileRequest
- type FeedLookup
- type FeedLookupFn
- type FeedType
- type FetchFeedRequest
- type FetchFeedRequests
- type FetchTwtsRequest
- type FmtOpts
- type Follow
- type FollowRequest
- type Follower
- type Followers
- type Follows
- type HashOption
- type HashOptions
- type Info
- type InjectRequest
- type KV
- type Link
- type LinkList
- type Links
- type MentionList
- type MuteRequest
- type OldProfile
- type PagedRequest
- type PagedResponse
- type PagerResponse
- type PostRequest
- type PostResponse
- type PreambleFeed
- type Profile
- type ProfileResponse
- type ReadSeekerReaderAt
- type RegisterRequest
- type ReportRequest
- type Subject
- type SupportRequest
- type SyncRequest
- type SyncResponse
- type TagList
- type Twt
- type TwtFile
- type TwtLink
- type TwtManager
- type TwtMap
- type TwtMention
- type TwtTag
- type TwtTextFormat
- type Twter
- type Twts
- func (twts Twts) Clone() Twts
- func (twts Twts) Len() int
- func (twts Twts) Less(i, j int) bool
- func (twts Twts) LinkCount() map[string]int
- func (twts Twts) Links() LinkList
- func (twts Twts) MentionCount() map[string]int
- func (twts Twts) Mentions() MentionList
- func (twts Twts) SubjectCount() map[string]int
- func (twts Twts) Subjects() []Subject
- func (twts Twts) Swap(i, j int)
- func (twts Twts) TagCount() map[string]int
- func (twts Twts) Tags() TagList
- func (twts *Twts) UnmarshalJSON(data []byte) error
- type UnfollowRequest
- type UnmuteRequest
- type Value
- type WhoAmIResponse
- type Yarn
- type Yarns
Constants ¶
const PreambleBufferSize = 2048
const (
// TwtHashLength is the encoded length (no. of characters) of a Twt's Hash (base32 encoded blake2b)
TwtHashLength = 7
)
Variables ¶
var ( ErrNotImplemented = errors.New("not implemented") ErrInvalidFeed = errors.New("erroneous feed detected") )
var NilTwt = &nilTwt{}
var PreambleMarker = []byte("#")
Functions ¶
func IsValidFeedType ¶
func NormalizeUsername ¶
func SetTwtManager ¶
func SetTwtManager(m TwtManager)
Types ¶
type ArchivedFeed ¶
type ArchivedFeed struct {
// contains filtered or unexported fields
}
func NewArchivedFeed ¶
func NewArchivedFeed(twter *Twter, hash, path string) *ArchivedFeed
func (*ArchivedFeed) Hash ¶
func (af *ArchivedFeed) Hash() string
func (*ArchivedFeed) Path ¶
func (af *ArchivedFeed) Path() string
func (*ArchivedFeed) String ¶
func (af *ArchivedFeed) String() string
func (*ArchivedFeed) Twter ¶
func (af *ArchivedFeed) Twter() *Twter
func (*ArchivedFeed) URL ¶
func (af *ArchivedFeed) URL() string
type AuthRequest ¶
AuthRequest ...
func NewAuthRequest ¶
func NewAuthRequest(r io.Reader) (req AuthRequest, err error)
NewAuthRequest ...
type ConversationRequest ¶
ConversationRequest ...
func NewConversationRequest ¶
func NewConversationRequest(r io.Reader) (req ConversationRequest, err error)
NewConversationRequest ...
type ErrDeadFeed ¶
type ErrDeadFeed struct {
Reason string
}
func (ErrDeadFeed) Error ¶
func (e ErrDeadFeed) Error() string
type ExternalProfileRequest ¶
ExternalProfileRequest ...
func NewExternalProfileRequest ¶
func NewExternalProfileRequest(r io.Reader) (req ExternalProfileRequest, err error)
NewExternalProfileRequest ...
type FeedLookup ¶
FeedLookup is a function that takes a username and returns a Twter
type FeedLookupFn ¶
func (FeedLookupFn) FeedLookup ¶
func (fn FeedLookupFn) FeedLookup(s string) *Twter
type FetchFeedRequest ¶
type FetchFeedRequest struct { Nick string URI string // Force whether or not to immediately fetch the feed and bypass Cache.ShouldRefreshFeed(). Force bool }
FetchFeedRequest is an single request for a twtxt.txt feed with a canonical Nickname and URL for the feed and optional request parameters that affect how the Cache fetches the feed.
func (FetchFeedRequest) String ¶
func (f FetchFeedRequest) String() string
String implements the Stringer interface and returns the Feed represented as a twtxt.txt URI in the form @<nick url>.
type FetchFeedRequests ¶
type FetchFeedRequests map[FetchFeedRequest]bool
FetchFeedRequests is a mapping of FetchFeedRequest to booleans used to ensure unique feeds Used by go.yarn.social/yarn/internal.Cache XXX: Probably shouldn't be here...
type FetchTwtsRequest ¶
type FetchTwtsRequest struct { URL string `json:"url"` Nick string `json:"nick"` Page int `json:"page"` }
FetchTwtsRequest ...
func NewFetchTwtsRequest ¶
func NewFetchTwtsRequest(r io.Reader) (req FetchTwtsRequest, err error)
NewFetchTwtsRequest ...
type Follow ¶
type FollowRequest ¶
FollowRequest ...
func NewFollowRequest ¶
func NewFollowRequest(r io.Reader) (req FollowRequest, err error)
NewFollowRequest ...
type Followers ¶
type Followers []*Follower
func (Followers) AsMap ¶
AsMap returns the Followers as a map of `nick -> uri` for use by the /whoFollows resource which implements the MultiUserAegent spec See: https://dev.twtxt.net/doc/useragentextension.html
type HashOption ¶
type HashOption func(opts *HashOptions)
HashOption allows for configurable Hash() behaviour such as WithHashLength() and WithHashNoCache
func WithHashLength ¶
func WithHashLength(length int) HashOption
WithHashLength sets the encoded (base32) hash length of the Twt hash (blake2b)
func WithHashNoCache ¶
func WithHashNoCache() HashOption
WithHashNoCache ignores the previously cached encoded hash and recomputes it (potentially with a new length)
type HashOptions ¶
HashOptions control hash encoding options for length and ignoring the previously cached encoded value and recomputing the hash (with potentially a longer length).
func NewHashOptions ¶
func NewHashOptions() *HashOptions
NewHashOptions returns a hashOptions with default values
type InjectRequest ¶
type InjectRequest struct {
Twt Twt `json:"twt"`
}
InjectRequest ...
func NewInjectRequest ¶
func NewInjectRequest(r io.Reader) (req InjectRequest, err error)
NewInjectRequest ...
type MentionList ¶
type MentionList []TwtMention
func (MentionList) IsMentioned ¶
func (ml MentionList) IsMentioned(twter Twter) bool
func (MentionList) Mentions ¶
func (ml MentionList) Mentions() []string
type MuteRequest ¶
MuteRequest ...
func NewMuteRequest ¶
func NewMuteRequest(r io.Reader) (req MuteRequest, err error)
NewMuteRequest ...
type OldProfile ¶
type OldProfile struct { Type string URL string // TODO: Rename to Nick Username string Avatar string // TODO: Rename to Description Tagline string Links Links // Used by the Mobile App for "Post as..." Feeds []string // `true` if the User viewing the Profile has muted this user/feed Muted bool // `true` if the User viewing the Profile follows this user/feed Follows bool // `true` if user/feed follows the User viewing the Profile. FollowedBy bool // Timestamp of the profile's last Twt LastPostedAt time.Time // Timestamp of the profile's last activity (last seen) accurate to a day LastSeenAt time.Time Bookmarks map[string]string NFollowing int Following map[string]string NFollowers int // TODO: Maybe migrate to use `Followers` type // XXX: But be aware doing so breaks API compat Followers map[string]string // `true` if the User viewing the Profile has permissions to show the // bookmarks/followers/followings of this user/feed ShowBookmarks bool ShowFollowers bool ShowFollowing bool }
OldProfile is a backwards compatible version of `Profile` for APIv1 client compatibility such as `yarnc` and the Mobile App that uses a map of `nick -> url` for Followers and Followings. TODO: Upgrade APIv1 clients TODOL Remove this when the Mobile App has been upgraded.
type PagedRequest ¶
type PagedRequest struct {
Page int `json:"page"`
}
PagedRequest ...
func NewPagedRequest ¶
func NewPagedRequest(r io.Reader) (req PagedRequest, err error)
NewPagedRequest ...
type PagedResponse ¶
type PagedResponse struct { Twts Twts `json:"twts"` Pager PagerResponse }
PagedResponse ...
type PagerResponse ¶
type PagerResponse struct { Current int `json:"current_page"` MaxPages int `json:"max_pages"` TotalTwts int `json:"total_twts"` }
PagerResponse ...
type PostRequest ¶
PostRequest ...
func NewPostRequest ¶
func NewPostRequest(r io.Reader) (req PostRequest, err error)
NewPostRequest ...
type PostResponse ¶
type PostResponse struct { Created string `json:"created"` Hash string `json:"hash"` Text string `json:"text"` }
PostResponse ...
type PreambleFeed ¶
type PreambleFeed struct {
// contains filtered or unexported fields
}
func ReadPreambleFeed ¶
func ReadPreambleFeed(r ReadSeekerReaderAt, size int64) (*PreambleFeed, error)
func (*PreambleFeed) Preamble ¶
func (p *PreambleFeed) Preamble() string
type Profile ¶
type Profile struct { Type string URI string Nick string Avatar string Description string Links Links // Used by the Mobile App for "Post as..." Feeds []string // `true` if the User viewing the Profile has muted this user/feed Muted bool // `true` if the User viewing the Profile follows this user/feed Follows bool // `true` if user/feed follows the User viewing the Profile. FollowedBy bool // Timestamp of the profile's last Twt LastPostedAt time.Time // Timestamp of the profile's last activity (last seen) accurate to a day LastSeenAt time.Time Bookmarks map[string]string NFollowing int Following Follows NFollowers int Followers Followers // `true` if the User viewing the Profile has permissions to show the // bookmarks/followers/followings of this user/feed ShowBookmarks bool ShowFollowers bool ShowFollowing bool }
Profile represents a user/feed profile
func (Profile) AsOldProfile ¶
func (p Profile) AsOldProfile() OldProfile
AsOldProfile returns a `Profilev1` object for compatibility with APIv1 clients such as the Mobile App. TODO: Remove when Mobile App is upgraded
type ProfileResponse ¶
type ProfileResponse struct { // TODO: Upgrade to `Profile` (v2) when Mobile App is upgraded Profile OldProfile `json:"profile"` Twter Twter `json:"twter"` }
ProfileResponse ...
type RegisterRequest ¶
type RegisterRequest struct { Username string `json:"username"` Password string `json:"password"` Email string `json:"email"` }
RegisterRequest ...
func NewRegisterRequest ¶
func NewRegisterRequest(r io.Reader) (req RegisterRequest, err error)
NewRegisterRequest ...
type ReportRequest ¶
type ReportRequest struct { Nick string `json:"nick"` URL string `json:"url"` Name string `json:"name"` Email string `json:"email"` Category string `json:"subject"` Message string `json:"message"` }
ReportRequest ...
func NewReportRequest ¶
func NewReportRequest(r io.Reader) (req ReportRequest, err error)
NewReportRequest ...
type SupportRequest ¶
type SupportRequest struct { Name string `json:"name"` Email string `json:"email"` Subject string `json:"subject"` Message string `json:"message"` }
SupportRequest ...
func NewSupportRequest ¶
func NewSupportRequest(r io.Reader) (req SupportRequest, err error)
NewSupportRequest ...
type SyncRequest ¶
type SyncRequest struct { Delete bool `json:"delete"` Feed string `json:"feed"` Body []byte `json:"body"` }
SyncRequest ...
func NewSyncRequest ¶
func NewSyncRequest(r io.Reader) (req SyncRequest, err error)
NewSyncRequest ...
type SyncResponse ¶
type SyncResponse struct { Success bool `json:"success"` Error string `json:"error"` Merged Twts `json:"merged"` }
SyncResponse ...
type Twt ¶
type Twt interface { IsZero() bool Clone() Twt Twter() Twter Created() time.Time Hash(...HashOption) string Subject() Subject Mentions() MentionList Links() LinkList Tags() TagList ExpandMentions(FmtOpts, FeedLookup) fmt.Formatter // TODO: remove FormatText and add func to update links for UI FormatText(TwtTextFormat, FmtOpts) string }
Twt ...
func DecodeJSON ¶
type TwtFile ¶
type TwtFile interface { Twter() *Twter Prev() *ArchivedFeed Info() Info Twts() Twts }
type TwtManager ¶
type TwtMention ¶
type TwtMention interface {
Twter() Twter
}
type TwtTextFormat ¶
type TwtTextFormat int
TwtTextFormat represents the format of which the twt text gets formatted to
const ( // MarkdownFmt to use markdown format MarkdownFmt TwtTextFormat = iota // ASFmt to use Activity Streams format (mostly HTML) ASFmt // HTMLFmt to use HTML format HTMLFmt // TextFmt to use for og:description TextFmt // LiteralFmt is the raw literal format as written/read to/from a feed LiteralFmt )
type Twter ¶
type Twter struct { Nick string `json:"nick"` URI string `json:"uri"` HashingURI string `json:"-"` // URL Deprecated field repalced by URI // Remove post Cache v20 URL string `json:"-"` Avatar string `json:"avatar"` Tagline string `json:"-"` Following int `json:"-"` Followers int `json:"-"` Follow map[string]Twter `json:"-"` // Metadata holds additinoal KV pairs (properties) of the feed // See: [Metadata Extension](https://dev.twtxt.net/doc/metadataextension.html) Metadata url.Values `json:"-"` }
Twter ...
func (Twter) DomainNick ¶
type Twts ¶
type Twts []Twt
Twts typedef to be able to attach sort methods
func (Twts) MentionCount ¶
func (Twts) SubjectCount ¶
func (*Twts) UnmarshalJSON ¶
type UnfollowRequest ¶
type UnfollowRequest struct {
Nick string `json:"nick"`
}
UnfollowRequest ...
func NewUnfollowRequest ¶
func NewUnfollowRequest(r io.Reader) (req UnfollowRequest, err error)
NewUnfollowRequest ...
type UnmuteRequest ¶
type UnmuteRequest struct {
Nick string `json:"nick"`
}
UnmuteRequest ...
func NewUnmuteRequest ¶
func NewUnmuteRequest(r io.Reader) (req UnmuteRequest, err error)
NewUnmuteRequest ...
type WhoAmIResponse ¶
type WhoAmIResponse struct {
Username string `json:"username"`
}
WhoAmIResponse ...