api

package
v1.1.69 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api contains methods used by dendrite components in multi-process mode to send requests to the appservice component, typically in order to ask an application service for some information.

Index

Constants

View Source
const (
	ASProtocolLegacyPath        = "/_matrix/app/unstable/thirdparty/protocol/"
	ASUserLegacyPath            = "/_matrix/app/unstable/thirdparty/user"
	ASLocationLegacyPath        = "/_matrix/app/unstable/thirdparty/location"
	ASRoomAliasExistsLegacyPath = "/rooms/"
	ASUserExistsLegacyPath      = "/users/"

	ASProtocolPath        = "/_matrix/app/v1/thirdparty/protocol/"
	ASUserPath            = "/_matrix/app/v1/thirdparty/user"
	ASLocationPath        = "/_matrix/app/v1/thirdparty/location"
	ASRoomAliasExistsPath = "/_matrix/app/v1/rooms/"
	ASUserExistsPath      = "/_matrix/app/v1/users/"
)

Variables

View Source
var ErrProfileNotExists = errors.New("no known profile for given user ID")

ErrProfileNotExists is returned when trying to lookup a user's profile that doesn't exist locally.

Functions

func RetrieveUserProfile

func RetrieveUserProfile(
	ctx context.Context,
	userID string,
	asAPI AppServiceInternalAPI,
	profileAPI userapi.ProfileAPI,
) (*authtypes.Profile, error)

RetrieveUserProfile is a wrapper that queries both the local database and application services for a given user's profile TODO: Remove this, it's called from federationapi and clientapi but is a pure function

Types

type ASLocationResponse

type ASLocationResponse struct {
	Alias    string          `json:"alias"`
	Protocol string          `json:"protocol"`
	Fields   json.RawMessage `json:"fields"`
}

type ASProtocolResponse

type ASProtocolResponse struct {
	FieldTypes     map[string]FieldType `json:"field_types,omitempty"` // NOTSPEC: field_types is required by the spec
	Icon           string               `json:"icon"`
	Instances      []ProtocolInstance   `json:"instances"`
	LocationFields []string             `json:"location_fields"`
	UserFields     []string             `json:"user_fields"`
}

type ASUserResponse

type ASUserResponse struct {
	Protocol string          `json:"protocol"`
	UserID   string          `json:"userid"`
	Fields   json.RawMessage `json:"fields"`
}

type AppServiceInternalAPI

type AppServiceInternalAPI interface {
	// Check whether a room alias exists within any application service namespaces
	RoomAliasExists(
		ctx context.Context,
		req *RoomAliasExistsRequest,
		resp *RoomAliasExistsResponse,
	) error
	// Check whether a user ID exists within any application service namespaces
	UserIDExists(
		ctx context.Context,
		req *UserIDExistsRequest,
		resp *UserIDExistsResponse,
	) error

	Locations(ctx context.Context, req *LocationRequest, resp *LocationResponse) error
	User(ctx context.Context, request *UserRequest, response *UserResponse) error
	Protocols(ctx context.Context, req *ProtocolRequest, resp *ProtocolResponse) error
}

AppServiceInternalAPI is used to query user and room alias data from application services

type FieldType

type FieldType struct {
	Placeholder string `json:"placeholder"`
	Regexp      string `json:"regexp"`
}

type LocationRequest

type LocationRequest struct {
	Protocol string `json:"protocol"`
	Params   string `json:"params"`
}

type LocationResponse

type LocationResponse struct {
	Locations []ASLocationResponse `json:"locations,omitempty"`
	Exists    bool                 `json:"exists,omitempty"`
}

type ProtocolInstance

type ProtocolInstance struct {
	Description string          `json:"desc"`
	Icon        string          `json:"icon,omitempty"`
	NetworkID   string          `json:"network_id,omitempty"` // NOTSPEC: network_id is required by the spec
	Fields      json.RawMessage `json:"fields,omitempty"`     // NOTSPEC: fields is required by the spec
}

type ProtocolRequest

type ProtocolRequest struct {
	Protocol string `json:"protocol,omitempty"`
}

type ProtocolResponse

type ProtocolResponse struct {
	Protocols map[string]ASProtocolResponse `json:"protocols"`
	Exists    bool                          `json:"exists"`
}

type RoomAliasExistsRequest

type RoomAliasExistsRequest struct {
	// Alias we want to lookup
	Alias string `json:"alias"`
}

RoomAliasExistsRequest is a request to an application service about whether a room alias exists

type RoomAliasExistsResponse

type RoomAliasExistsResponse struct {
	AliasExists bool `json:"exists"`
}

RoomAliasExistsResponse is a response from an application service about whether a room alias exists

type UserIDExistsRequest

type UserIDExistsRequest struct {
	// UserID we want to lookup
	UserID string `json:"user_id"`
}

UserIDExistsRequest is a request to an application service about whether a user ID exists

type UserIDExistsRequestAccessToken

type UserIDExistsRequestAccessToken struct {
	// UserID we want to lookup
	UserID      string `json:"user_id"`
	AccessToken string `json:"access_token"`
}

UserIDExistsRequestAccessToken is a request to an application service about whether a user ID exists. Includes an access token

type UserIDExistsResponse

type UserIDExistsResponse struct {
	UserIDExists bool `json:"exists"`
}

UserIDExistsResponse is a response from an application service about whether a user ID exists

type UserRequest

type UserRequest struct {
	Protocol string `json:"protocol"`
	Params   string `json:"params"`
}

type UserResponse

type UserResponse struct {
	Users  []ASUserResponse `json:"users,omitempty"`
	Exists bool             `json:"exists,omitempty"`
}

Jump to

Keyboard shortcuts

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