Documentation ¶
Index ¶
- Constants
- func DeriveEmojisFromText(text string) []string
- func DeriveHashtagsFromText(text string) []string
- func DeriveMentionNamesFromText(text string) []string
- func EmptyTimelineResponse() *apimodel.TimelineResponse
- 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 PackageTimelineableResponse(params TimelineableResponseParams) (*apimodel.TimelineResponse, gtserror.WithCode)
- func UniqueStrings(s []string) []string
- func UniqueURIs(s []*url.URL) []*url.URL
- type TimelineableResponseParams
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 DeriveEmojisFromText ¶
DeriveEmojisFromText takes a plaintext (ie., not html-formatted) text, and applies a regex to it to return a deduplicated list of emojis used in that text, without the surrounding `::`
func DeriveHashtagsFromText ¶
DeriveHashtagsFromText takes a plaintext (ie., not html-formatted) text, and applies a regex to it to return a deduplicated list of hashtags used in that text, without the leading #. The case of the returned tags will be lowered, for consistency.
func DeriveMentionNamesFromText ¶ added in v0.2.2
DeriveMentionNamesFromText takes a plaintext (ie., not html-formatted) text, and applies a regex to it to return a deduplicated list of account names mentioned in that text, in the format "@user@example.org" or "@username" for local users.
func EmptyTimelineResponse ¶ added in v0.3.5
func EmptyTimelineResponse() *apimodel.TimelineResponse
EmptyTimelineResponse just returns an empty TimelineResponse 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 PackageTimelineableResponse ¶ added in v0.3.5
func PackageTimelineableResponse(params TimelineableResponseParams) (*apimodel.TimelineResponse, gtserror.WithCode)
PackageTimelineableResponse is a convenience function for returning a bunch of timelineable items (notifications, statuses, etc), as well as a Link header to inform callers of where to find next/prev items.
func UniqueStrings ¶
UniqueStrings returns a deduplicated version of a given string slice.
Types ¶
type TimelineableResponseParams ¶ added in v0.3.5
type TimelineableResponseParams struct { Items []timeline.Timelineable // Sorted slice of Timelineables (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' }
TimelineableResponseParams models the parameters to pass to PackageTimelineableResponse.
The given items will be provided in the timeline 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.