users

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UsernameKey is for account usernames.
	UsernameKey = "username"
	// StatusIDKey is for status IDs
	StatusIDKey = "status"
	// OnlyOtherAccountsKey is for filtering status responses.
	OnlyOtherAccountsKey = "only_other_accounts"
	// MinIDKey is for filtering status responses.
	MinIDKey = "min_id"
	// MaxIDKey is for filtering status responses.
	MaxIDKey = "max_id"
	// PageKey is for filtering status responses.
	PageKey = "page"

	// BasePath is the base path for serving AP 'users' requests, minus the 'users' prefix.
	BasePath = "/:" + UsernameKey
	// InboxPath is for serving POST requests to a user's inbox with the given username key.
	InboxPath = BasePath + "/" + uris.InboxPath
	// OutboxPath is for serving GET requests to a user's outbox with the given username key.
	OutboxPath = BasePath + "/" + uris.OutboxPath
	// FollowersPath is for serving GET request's to a user's followers list, with the given username key.
	FollowersPath = BasePath + "/" + uris.FollowersPath
	// FollowingPath is for serving GET request's to a user's following list, with the given username key.
	FollowingPath = BasePath + "/" + uris.FollowingPath
	// FeaturedCollectionPath is for serving GET requests to a user's list of featured (pinned) statuses.
	FeaturedCollectionPath = BasePath + "/" + uris.CollectionsPath + "/" + uris.FeaturedPath
	// StatusPath is for serving GET requests to a particular status by a user, with the given username key and status ID
	StatusPath = BasePath + "/" + uris.StatusesPath + "/:" + StatusIDKey
	// StatusRepliesPath is for serving the replies collection of a status.
	StatusRepliesPath = StatusPath + "/replies"
	// AcceptPath is for serving accepts of a status.
	AcceptPath = BasePath + "/" + uris.AcceptsPath + "/:" + apiutil.IDKey
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(processor *processing.Processor) *Module

func (*Module) AcceptGETHandler added in v0.17.0

func (m *Module) AcceptGETHandler(c *gin.Context)

AcceptGETHandler serves an interaction request as an ActivityStreams Accept.

func (*Module) FeaturedCollectionGETHandler added in v0.8.0

func (m *Module) FeaturedCollectionGETHandler(c *gin.Context)

FeaturedCollectionGETHandler swagger:operation GET /users/{username}/collections/featured s2sFeaturedCollectionGet

Get the featured collection (pinned posts) for a user.

The response will contain an ordered collection of Note URIs in the `items` property.

It is up to the caller to dereference the provided Note URIs (or not, if they already have them cached).

HTTP signature is required on the request.

---
tags:
- s2s/federation

produces:
- application/activity+json

parameters:
-
	name: username
	type: string
	description: Account name of the user
	in: path
	required: true

responses:
	'200':
		in: body
		schema:
			"$ref": "#/definitions/swaggerFeaturedCollection"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden
	'404':
		description: not found

func (*Module) FollowersGETHandler

func (m *Module) FollowersGETHandler(c *gin.Context)

FollowersGETHandler returns a collection of URIs for followers of the target user, formatted so that other AP servers can understand it.

func (*Module) FollowingGETHandler

func (m *Module) FollowingGETHandler(c *gin.Context)

FollowingGETHandler returns a collection of URIs for accounts that the target user follows, formatted so that other AP servers can understand it.

func (*Module) InboxPOSTHandler

func (m *Module) InboxPOSTHandler(c *gin.Context)

InboxPOSTHandler deals with incoming POST requests to an actor's inbox. Eg., POST to https://example.org/users/whatever/inbox.

func (*Module) OutboxGETHandler

func (m *Module) OutboxGETHandler(c *gin.Context)

OutboxGETHandler swagger:operation GET /users/{username}/outbox s2sOutboxGet

Get the public outbox collection for an actor.

Note that the response will be a Collection with a page as `first`, as shown below, if `page` is `false`.

If `page` is `true`, then the response will be a single `CollectionPage` without the wrapping `Collection`.

HTTP signature is required on the request.

---
tags:
- s2s/federation

produces:
- application/activity+json

parameters:
-
	name: username
	type: string
	description: Username of the account.
	in: path
	required: true
-
	name: page
	type: boolean
	description: Return response as a CollectionPage.
	in: query
	default: false
-
	name: min_id
	type: string
	description: Minimum ID of the next status, used for paging.
	in: query
-
	name: max_id
	type: string
	description: Maximum ID of the next status, used for paging.
	in: query

responses:
	'200':
		in: body
		schema:
			"$ref": "#/definitions/swaggerCollection"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden
	'404':
		description: not found

func (*Module) Route

func (m *Module) Route(attachHandler func(method string, path string, f ...gin.HandlerFunc) gin.IRoutes)

func (*Module) StatusGETHandler

func (m *Module) StatusGETHandler(c *gin.Context)

StatusGETHandler serves the target status as an activitystreams NOTE so that other AP servers can parse it.

func (*Module) StatusRepliesGETHandler

func (m *Module) StatusRepliesGETHandler(c *gin.Context)

StatusRepliesGETHandler swagger:operation GET /users/{username}/statuses/{status}/replies s2sRepliesGet

Get the replies collection for a status.

Note that the response will be a Collection with a page as `first`, as shown below, if `page` is `false`.

If `page` is `true`, then the response will be a single `CollectionPage` without the wrapping `Collection`.

HTTP signature is required on the request.

---
tags:
- s2s/federation

produces:
- application/activity+json

parameters:
-
	name: username
	type: string
	description: Username of the account.
	in: path
	required: true
-
	name: status
	type: string
	description: ID of the status.
	in: path
	required: true
-
	name: page
	type: boolean
	description: Return response as a CollectionPage.
	in: query
	default: false
-
	name: only_other_accounts
	type: boolean
	description: Return replies only from accounts other than the status owner.
	in: query
	default: false
-
	name: min_id
	type: string
	description: Minimum ID of the next status, used for paging.
	in: query

responses:
	'200':
		in: body
		schema:
			"$ref": "#/definitions/swaggerCollection"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden
	'404':
		description: not found

func (*Module) UsersGETHandler

func (m *Module) UsersGETHandler(c *gin.Context)

UsersGETHandler should be served at https://example.org/users/:username.

The goal here is to return the activitypub representation of an account in the form of a vocab.ActivityStreamsPerson. This should only be served to REMOTE SERVERS that present a valid signature on the GET request, on behalf of a user, otherwise we risk leaking information about users publicly.

And of course, the request should be refused if the account or server making the request is blocked.

type SwaggerCollection

type SwaggerCollection struct {
	// ActivityStreams JSON-LD context.
	// A string or an array of strings, or more
	// complex nested items.
	// example: https://www.w3.org/ns/activitystreams
	Context interface{} `json:"@context"`
	// ActivityStreams ID.
	// example: https://example.org/users/some_user/statuses/106717595988259568/replies
	ID string `json:"id"`
	// ActivityStreams type.
	// example: Collection
	Type string `json:"type"`
	// ActivityStreams first property.
	First SwaggerCollectionPage `json:"first"`
	// ActivityStreams last property.
	Last SwaggerCollectionPage `json:"last,omitempty"`
}

SwaggerCollection represents an ActivityPub Collection. swagger:model swaggerCollection

type SwaggerCollectionPage

type SwaggerCollectionPage struct {
	// ActivityStreams ID.
	// example: https://example.org/users/some_user/statuses/106717595988259568/replies?page=true
	ID string `json:"id"`
	// ActivityStreams type.
	// example: CollectionPage
	Type string `json:"type"`
	// Link to the next page.
	// example: https://example.org/users/some_user/statuses/106717595988259568/replies?only_other_accounts=true&page=true
	Next string `json:"next"`
	// Collection this page belongs to.
	// example: https://example.org/users/some_user/statuses/106717595988259568/replies
	PartOf string `json:"partOf"`
	// Items on this page.
	// example: ["https://example.org/users/some_other_user/statuses/086417595981111564", "https://another.example.com/users/another_user/statuses/01FCN8XDV3YG7B4R42QA6YQZ9R"]
	Items []string `json:"items"`
}

SwaggerCollectionPage represents one page of a collection. swagger:model swaggerCollectionPage

type SwaggerFeaturedCollection added in v0.8.0

type SwaggerFeaturedCollection struct {
	// ActivityStreams JSON-LD context.
	// A string or an array of strings, or more
	// complex nested items.
	// example: https://www.w3.org/ns/activitystreams
	Context interface{} `json:"@context"`
	// ActivityStreams ID.
	// example: https://example.org/users/some_user/collections/featured
	ID string `json:"id"`
	// ActivityStreams type.
	// example: OrderedCollection
	Type string `json:"type"`
	// List of status URIs.
	// example: ["https://example.org/users/some_user/statuses/01GSZ0F7Q8SJKNRF777GJD271R", "https://example.org/users/some_user/statuses/01GSZ0G012CBQ7TEKX689S3QRE"]
	Items []string `json:"items"`
	// Number of items in this collection.
	// example: 2
	TotalItems int
}

SwaggerFeaturedCollection represents an ActivityPub OrderedCollection. swagger:model swaggerFeaturedCollection

Jump to

Keyboard shortcuts

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