Documentation ¶
Index ¶
- Constants
- func DePunify(domain string) (string, error)
- func EmptyPageableResponse() *apimodel.PageableResponse
- func ExtractNamestringParts(mention string) (username, host string, err error)
- func ExtractWebfingerParts(webfinger string) (username, host string, err error)
- func FormatISO8601(t time.Time) string
- func IsMentionOrHashtagBoundary(r rune) bool
- func IsPermittedInHashtag(r rune) bool
- func IsPlausiblyInHashtag(r rune) bool
- func PackagePageableResponse(params PageableResponseParams) (*apimodel.PageableResponse, gtserror.WithCode)
- func ParseISO8601(in string) (time.Time, error)
- func Ptr[T any](t T) *T
- func Punify(domain string) (string, error)
- func ShortcodeDomain(emoji *gtsmodel.Emoji) string
- func UniqueStrings(strings []string) []string
- func UniqueURIs(uris []*url.URL) []*url.URL
- type PageableResponseParams
Constants ¶
const ISO8601 = "2006-01-02T15:04:05.000Z"
ISO8601 is a formatter for serializing times that forces ISO8601 behavior.
Variables ¶
This section is empty.
Functions ¶
func DePunify ¶ added in v0.9.0
DePunify converts the given punycode string to its original unicode representation (lowercased). Noop if the domain is (already) not puny.
Returns an error if conversion fails.
func EmptyPageableResponse ¶ added in v0.6.0
func EmptyPageableResponse() *apimodel.PageableResponse
EmptyPageableResponse just returns an empty PageableResponse with no link header or items.
func ExtractNamestringParts ¶ added in v0.3.5
ExtractNamestringParts extracts the username test_user and the domain example.org from a string like @test_user@example.org.
If nothing is matched, it will return an error.
func ExtractWebfingerParts ¶ added in v0.3.5
ExtractWebfingerParts returns username test_user and domain example.org from a string like acct:test_user@example.org, or acct:@test_user@example.org.
If nothing is extracted, it will return an error.
func FormatISO8601 ¶ added in v0.3.4
FormatISO8601 converts the given time to UTC and then formats it using the ISO8601 const, which the Mastodon API is able to understand.
func IsMentionOrHashtagBoundary ¶ added in v0.7.0
Decides where to break before or after a #hashtag or @mention
func IsPermittedInHashtag ¶ added in v0.7.0
func IsPlausiblyInHashtag ¶ added in v0.7.0
func PackagePageableResponse ¶ added in v0.6.0
func PackagePageableResponse(params PageableResponseParams) (*apimodel.PageableResponse, gtserror.WithCode)
PackagePageableResponse is a convenience function for returning a bunch of pageable items (notifications, statuses, etc), as well as a Link header to inform callers of where to find next/prev items.
func ParseISO8601 ¶ added in v0.6.0
ParseISO8601 parses the given time string according to the ISO8601 const.
func Punify ¶ added in v0.9.0
Punify converts the given domain to lowercase then to punycode (for international domain names).
Returns the resulting domain or an error if the punycode conversion fails.
func ShortcodeDomain ¶ added in v0.7.0
ShortcodeDomain returns the [shortcode]@[domain] for the given emoji.
func UniqueStrings ¶
UniqueStrings returns a deduplicated version of the given slice of strings, without changing the order of the entries.
Types ¶
type PageableResponseParams ¶ added in v0.6.0
type PageableResponseParams struct { Items []interface{} // Sorted slice of items (statuses, notifications, etc) Path string // path to use for next/prev queries in the link header NextMaxIDKey string // key to use for the next max id query param in the link header, defaults to 'max_id' NextMaxIDValue string // value to use for next max id PrevMinIDKey string // key to use for the prev min id query param in the link header, defaults to 'min_id' PrevMinIDValue string // value to use for prev min id Limit int // limit number of entries to return ExtraQueryParams []string // any extra query parameters to provide in the link header, should be in the format 'example=value' }
PageableResponseParams models the parameters to pass to PackagePageableResponse.
The given items will be provided in the paged response.
The other values are all used to create the Link header so that callers know which endpoint to query next and previously in order to do paging.