uris

package
v0.17.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UsersPath        = "users"         // UsersPath is for serving users info
	StatusesPath     = "statuses"      // StatusesPath is for serving statuses
	InboxPath        = "inbox"         // InboxPath represents the activitypub inbox location
	OutboxPath       = "outbox"        // OutboxPath represents the activitypub outbox location
	FollowersPath    = "followers"     // FollowersPath represents the activitypub followers location
	FollowingPath    = "following"     // FollowingPath represents the activitypub following location
	LikedPath        = "liked"         // LikedPath represents the activitypub liked location
	CollectionsPath  = "collections"   // CollectionsPath represents the activitypub collections location
	FeaturedPath     = "featured"      // FeaturedPath represents the activitypub featured location
	PublicKeyPath    = "main-key"      // PublicKeyPath is for serving an account's public key
	FollowPath       = "follow"        // FollowPath used to generate the URI for an individual follow or follow request
	UpdatePath       = "updates"       // UpdatePath is used to generate the URI for an account update
	BlocksPath       = "blocks"        // BlocksPath is used to generate the URI for a block
	MovesPath        = "moves"         // MovesPath is used to generate the URI for a move
	ReportsPath      = "reports"       // ReportsPath is used to generate the URI for a report/flag
	ConfirmEmailPath = "confirm_email" // ConfirmEmailPath is used to generate the URI for an email confirmation link
	FileserverPath   = "fileserver"    // FileserverPath is a path component for serving attachments + media
	EmojiPath        = "emoji"         // EmojiPath represents the activitypub emoji location
	TagsPath         = "tags"          // TagsPath represents the activitypub tags location
	AcceptsPath      = "accepts"       // AcceptsPath represents the activitypub Accept's location
	RejectsPath      = "rejects"       // RejectsPath represents the activitypub Reject's location
)

Variables

This section is empty.

Functions

func GenerateURIForAccept added in v0.17.0

func GenerateURIForAccept(username string, thisAcceptID string) string

GenerateURIForAccept returns the AP URI for a new Accept activity -- something like: https://example.org/users/whatever_user/accepts/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForBlock

func GenerateURIForBlock(username string, thisBlockID string) string

GenerateURIForBlock returns the AP URI for a new block activity -- something like: https://example.org/users/whatever_user/blocks/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForEmailConfirm

func GenerateURIForEmailConfirm(token string) string

GenerateURIForEmailConfirm returns a link for email confirmation -- something like: https://example.org/confirm_email?token=490e337c-0162-454f-ac48-4b22bb92a205

func GenerateURIForFollow

func GenerateURIForFollow(username string, thisFollowID string) string

GenerateURIForFollow returns the AP URI for a new follow -- something like: https://example.org/users/whatever_user/follow/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForLike

func GenerateURIForLike(username string, thisFavedID string) string

GenerateURIForLike returns the AP URI for a new like/fave -- something like: https://example.org/users/whatever_user/liked/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForMove added in v0.15.0

func GenerateURIForMove(username string, thisMoveID string) string

GenerateURIForMove returns the AP URI for a new Move activity -- something like: https://example.org/users/whatever_user/moves/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForReject added in v0.17.0

func GenerateURIForReject(username string, thisRejectID string) string

GenerateURIForReject returns the AP URI for a new Reject activity -- something like: https://example.org/users/whatever_user/rejects/01F7XTH1QGBAPMGF49WJZ91XGC

func GenerateURIForReport added in v0.7.0

func GenerateURIForReport(thisReportID string) string

GenerateURIForReport returns the API URI for a new Flag activity -- something like: https://example.org/reports/01GP3AWY4CRDVRNZKW0TEAMB5R

This path specifically doesn't contain any info about the user who did the reporting, to protect their privacy.

func GenerateURIForUpdate

func GenerateURIForUpdate(username string, thisUpdateID string) string

GenerateURIForUpdate returns the AP URI for a new update activity -- something like: https://example.org/users/whatever_user#updates/01F7XTH1QGBAPMGF49WJZ91XGC

func IsAcceptsPath added in v0.17.0

func IsAcceptsPath(id *url.URL) bool

IsAcceptsPath returns true if the given URL path corresponds to eg /users/example_username/accepts/SOME_ULID_OF_AN_ACCEPT

func IsBlockPath

func IsBlockPath(id *url.URL) bool

IsBlockPath returns true if the given URL path corresponds to eg /users/example_username/blocks/SOME_ULID_OF_A_BLOCK

func IsFollowPath

func IsFollowPath(id *url.URL) bool

IsFollowPath returns true if the given URL path corresponds to eg /users/example_username/follow/SOME_ULID_OF_A_FOLLOW

func IsFollowersPath

func IsFollowersPath(id *url.URL) bool

IsFollowersPath returns true if the given URL path corresponds to eg /users/example_username/followers

func IsFollowingPath

func IsFollowingPath(id *url.URL) bool

IsFollowingPath returns true if the given URL path corresponds to eg /users/example_username/following

func IsInboxPath

func IsInboxPath(id *url.URL) bool

IsInboxPath returns true if the given URL path corresponds to eg /users/example_username/inbox

func IsLikePath

func IsLikePath(id *url.URL) bool

IsLikePath returns true if the given URL path corresponds to eg /users/example_username/liked/SOME_ULID_OF_A_STATUS

func IsLikedPath

func IsLikedPath(id *url.URL) bool

IsLikedPath returns true if the given URL path corresponds to eg /users/example_username/liked

func IsOutboxPath

func IsOutboxPath(id *url.URL) bool

IsOutboxPath returns true if the given URL path corresponds to eg /users/example_username/outbox

func IsPublicKeyPath

func IsPublicKeyPath(id *url.URL) bool

IsPublicKeyPath returns true if the given URL path corresponds to eg /users/example_username/main-key

func IsReportPath added in v0.7.0

func IsReportPath(id *url.URL) bool

IsReportPath returns true if the given URL path corresponds to eg /reports/SOME_ULID_OF_A_REPORT

func IsStatusesPath

func IsStatusesPath(id *url.URL) bool

IsStatusesPath returns true if the given URL path corresponds to eg /users/example_username/statuses/SOME_ULID_OF_A_STATUS

func IsUserPath

func IsUserPath(id *url.URL) bool

IsUserPath returns true if the given URL path corresponds to eg /users/example_username

func IsUserWebPath added in v0.13.3

func IsUserWebPath(id *url.URL) bool

IsUserWebPath returns true if the given URL path corresponds to eg /@example_username

func ParseBlockPath

func ParseBlockPath(id *url.URL) (username string, ulid string, err error)

ParseBlockPath returns the username and ulid from a path such as /users/example_username/blocks/SOME_ULID_OF_A_BLOCK

func ParseFollowersPath

func ParseFollowersPath(id *url.URL) (username string, err error)

ParseFollowersPath returns the username from a path such as /users/example_username/followers

func ParseFollowingPath

func ParseFollowingPath(id *url.URL) (username string, err error)

ParseFollowingPath returns the username from a path such as /users/example_username/following

func ParseInboxPath

func ParseInboxPath(id *url.URL) (username string, err error)

ParseInboxPath returns the username from a path such as /users/example_username/inbox

func ParseLikedPath

func ParseLikedPath(id *url.URL) (username string, ulid string, err error)

ParseLikedPath returns the username and ulid from a path such as /users/example_username/liked/SOME_ULID_OF_A_STATUS

func ParseOutboxPath

func ParseOutboxPath(id *url.URL) (username string, err error)

ParseOutboxPath returns the username from a path such as /users/example_username/outbox

func ParseReportPath added in v0.7.0

func ParseReportPath(id *url.URL) (ulid string, err error)

ParseReportPath returns the ulid from a path such as /reports/SOME_ULID_OF_A_REPORT

func ParseStatusesPath

func ParseStatusesPath(id *url.URL) (username string, ulid string, err error)

ParseStatusesPath returns the username and ulid from a path such as /users/example_username/statuses/SOME_ULID_OF_A_STATUS

func ParseUserPath

func ParseUserPath(id *url.URL) (username string, err error)

ParseUserPath returns the username from a path such as /users/example_username

func ParseUserWebPath added in v0.13.3

func ParseUserWebPath(id *url.URL) (username string, err error)

ParseUserPath returns the username from a path such as /@example_username

func StoragePathForAttachment added in v0.13.0

func StoragePathForAttachment(
	accountID string,
	mediaType string,
	mediaSize string,
	mediaID string,
	extension string,
) string

StoragePathForAttachment generates a storage path for an attachment/emoji/header etc.

Will produce something like:

"01FPST95B8FC3HG3AGCDKPQNQ2/attachment/original/01FPST9QK4V5XWS3F9Z4F2G1X7.gif"

func URIForAttachment added in v0.13.0

func URIForAttachment(
	accountID string,
	mediaType string,
	mediaSize string,
	mediaID string,
	extension string,
) string

URIForAttachment generates a URI for an attachment/emoji/header etc.

Will produce something like:

"https://example.org/fileserver/01FPST95B8FC3HG3AGCDKPQNQ2/attachment/original/01FPST9QK4V5XWS3F9Z4F2G1X7.gif"

func URIForEmoji added in v0.13.0

func URIForEmoji(emojiID string) string

URIForEmoji generates an ActivityPub URI for an emoji.

Will produce something like:

"https://example.org/emoji/01FPST9QK4V5XWS3F9Z4F2G1X7"

func URIForTag added in v0.13.0

func URIForTag(name string) string

URIForTag generates an activitypub uri for a tag.

Types

type UserURIs

type UserURIs struct {
	// The web URL of the instance host, eg https://example.org
	HostURL string
	// The web URL of the user, eg., https://example.org/@example_user
	UserURL string
	// The web URL for statuses of this user, eg., https://example.org/@example_user/statuses
	StatusesURL string

	// The activitypub URI of this user, eg., https://example.org/users/example_user
	UserURI string
	// The activitypub URI for this user's statuses, eg., https://example.org/users/example_user/statuses
	StatusesURI string
	// The activitypub URI for this user's activitypub inbox, eg., https://example.org/users/example_user/inbox
	InboxURI string
	// The activitypub URI for this user's activitypub outbox, eg., https://example.org/users/example_user/outbox
	OutboxURI string
	// The activitypub URI for this user's followers, eg., https://example.org/users/example_user/followers
	FollowersURI string
	// The activitypub URI for this user's following, eg., https://example.org/users/example_user/following
	FollowingURI string
	// The activitypub URI for this user's liked posts eg., https://example.org/users/example_user/liked
	LikedURI string
	// The activitypub URI for this user's featured collections, eg., https://example.org/users/example_user/collections/featured
	FeaturedCollectionURI string
	// The URI for this user's public key, eg., https://example.org/users/example_user/publickey
	PublicKeyURI string
}

UserURIs contains a bunch of UserURIs and URLs for a user, host, account, etc.

func GenerateURIsForAccount

func GenerateURIsForAccount(username string) *UserURIs

GenerateURIsForAccount throws together a bunch of URIs for the given username, with the given protocol and host.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL