routing

package
v0.0.0-...-9835270 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: AGPL-3.0, Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const MaxReqRooms = 50
View Source
const MaxReqUserInfoUsers = 50

Variables

View Source
var (
	ErrRoomDontExist = errors.New("Room does not exist")
	ErrQryRoomState  = errors.New("Query room state failed")
)

Functions

func AddUserInfo

func AddUserInfo(
	ctx context.Context, r *external.PostUserInfoRequest,
	accountDB model.AccountsDatabase,
	userID string, cfg *config.Dendrite,
	cache service.Cache,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

AddUserInfo implements POST /user_info/{userID}

func BuildMembershipAndFireEvents

func BuildMembershipAndFireEvents(
	ctx context.Context,
	rooms []string,
	newProfile authtypes.Profile, userID string, cfg *config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,
	idg *uid.UidGenerator,
)

func CheckAndSave3PIDAssociation

func CheckAndSave3PIDAssociation() (int, core.Coder)

CheckAndSave3PIDAssociation implements POST /account/3pid

func CreateRoom

CreateRoom implements /createRoom

func DeleteDeviceByID

func DeleteDeviceByID(
	ctx context.Context,
	delReq *external.DelDeviceRequest,
	deviceID string,
	cfg config.Dendrite,
	cache service.Cache,
	encryptDB model.EncryptorAPIDatabase,
	tokenFilter *filter.Filter,
	syncDB model.SyncAPIDatabase,
	deviceDB model.DeviceDatabase,
	rpcClient *common.RpcClient,
) (int, core.Coder)

DeleteDeviceByID handles Delete on /devices/{deviceID} Deletes the given device, and invalidates any access token associated with it. accountDB model.AccountsDatabase, deviceDB model.DeviceDatabase,

func DeleteDevices

func DeleteDevices(
	ctx context.Context,
	req *external.PostDelDevicesRequest,
	device *authtypes.Device,
	cache service.Cache,
	encryptDB model.EncryptorAPIDatabase,
	tokenFilter *filter.Filter,
	syncDB model.SyncAPIDatabase,
	deviceDB model.DeviceDatabase,
	rpcClient *common.RpcClient,
) (int, core.Coder)

func DeleteRoomTag

func DeleteRoomTag(
	ctx context.Context,
	req *external.DelRoomsTagsByIDRequest,
	accountDB model.AccountsDatabase,
	userID string,
	cfg config.Dendrite,
) (int, core.Coder)

func DeleteUserInfo

func DeleteUserInfo(
	ctx context.Context,
	req *external.DeleteUserInfoRequest,
	cfg config.Dendrite,
	federation *fed.Federation,
	accountDB model.AccountsDatabase,
	cache service.Cache,
) (int, core.Coder)

DeleteUserInfo implements DELETE /user_info/{userID}

func DirectoryRoom

func DirectoryRoom(
	ctx context.Context,
	roomAlias string,
	federation *fed.Federation,
	cfg *config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,

) (int, core.Coder)

DirectoryRoom looks up a room alias

func DismissRoom

func DismissRoom(
	ctx context.Context, req *external.DismissRoomRequest, accountDB model.AccountsDatabase,
	ownerID, deviceID, roomID string,
	cfg config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,
	federation *fed.Federation,
	cache service.Cache,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

func Forget3PID

func Forget3PID() (int, core.Coder)

Forget3PID implements POST /account/3pid/delete

func GenNewToken

func GenNewToken(
	ctx context.Context,
	deviceDB model.DeviceDatabase,
	device *authtypes.Device,
	tokenFilter *filter.Filter,
	idg *uid.UidGenerator,
	cfg config.Dendrite,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	rpcClient *common.RpcClient,
) (int, core.Coder)

func GetAssociated3PIDs

func GetAssociated3PIDs() (int, core.Coder)

GetAssociated3PIDs implements GET /account/3pid

func GetAvatarURL

func GetAvatarURL(
	ctx context.Context,
	userID string,
	cfg config.Dendrite,
	accountDB model.AccountsDatabase,
	cache service.Cache,
	federation *fed.Federation,
	complexCache *common.ComplexCache,
	roomDB model.RoomServerDatabase,
) (int, core.Coder)

GetAvatarURL implements GET /profile/{userID}/avatar_url

func GetDeviceByID

func GetDeviceByID(
	cache service.Cache,
	userID, deviceID string,
) (int, core.Coder)

GetDeviceByID handles /device/{deviceID}

func GetDevicesByUserID

func GetDevicesByUserID(
	cache service.Cache, userID string,
) (int, core.Coder)

GetDevicesByUserID handles /devices

func GetDisplayName

func GetDisplayName(
	ctx context.Context, userID string, cfg config.Dendrite,
	accountDB model.AccountsDatabase,
	cache service.Cache, federation *fed.Federation,
	complexCache *common.ComplexCache,
	roomDB model.RoomServerDatabase,
) (int, core.Coder)

GetDisplayName implements GET /profile/{userID}/displayname

func GetFilter

func GetFilter(
	ctx context.Context,
	req *external.GetUserFilterRequest,
	userID string,
	cache service.Cache,
) (int, core.Coder)

GetFilter implements GET /_matrix/client/r0/user/{userId}/filter/{filterId}

func GetPresenceByID

func GetPresenceByID(
	rpcCli *common.RpcClient,
	cache service.Cache,
	federation *fed.Federation,
	cfg *config.Dendrite,
	userID string,
) (int, core.Coder)

func GetPresenceListByID

func GetPresenceListByID() (int, core.Coder)

func GetProfile

func GetProfile(
	ctx context.Context,
	req *external.GetProfileRequest,
	cfg config.Dendrite,
	federation *fed.Federation,
	accountDB model.AccountsDatabase,
	cache service.Cache,
	complexCache *common.ComplexCache,
	roomDB model.RoomServerDatabase,
) (int, core.Coder)

GetProfile implements GET /profile/{userID}

func GetProfiles

func GetProfiles(
	ctx context.Context,
	req *external.GetProfilesRequest,
	cfg config.Dendrite,
	federation *fed.Federation,
	accountDB model.AccountsDatabase,
	cache service.Cache,
	complexCache *common.ComplexCache,
	roomDB model.RoomServerDatabase,
) (int, core.Coder)

GetProfiles implements GET /profiles

func GetRoomTags

func GetRoomTags(
	ctx context.Context,
	cache service.Cache,
	userID string,
	r *external.GetRoomsTagsByIDRequest,
) (int, core.Coder)

func GetSuperAdminToken

func GetSuperAdminToken(
	ctx context.Context,
	deviceDB model.DeviceDatabase,
	device *authtypes.Device,
	tokenFilter *filter.Filter,
	idg *uid.UidGenerator,
	cfg config.Dendrite,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	rpcClient *common.RpcClient,
) (int, core.Coder)

func GetUserInfo

func GetUserInfo(
	ctx context.Context,
	req *external.GetUserInfoRequest,
	cfg config.Dendrite,
	federation *fed.Federation,
	accountDB model.AccountsDatabase,
	cache service.Cache,
) (int, core.Coder)

GetUserInfo implements GET /user_info/{userID}

func GetUserInfoList

func GetUserInfoList(
	ctx context.Context,
	req *external.GetUserInfoListRequest,
	cfg config.Dendrite,
	federation *fed.Federation,
	accountDB model.AccountsDatabase,
	cache service.Cache,
) (int, core.Coder)

GetUserInfoList implements GET /user_info_list

func GetVisibility

func GetVisibility(
	ctx context.Context,
	roomID string,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
) (int, core.Coder)

GetVisibility implements GET /directory/list/room/{roomID}

func GetWhoAmi

func GetWhoAmi(
	userID string,
) (int, core.Coder)

func JoinRoomByIDOrAlias

func JoinRoomByIDOrAlias(
	ctx context.Context,
	r *external.PostRoomsJoinByAliasRequest,
	userID string,
	roomIDOrAlias string,
	cfg config.Dendrite,
	federation *fed.Federation,
	rpcCli roomserverapi.RoomserverRPCAPI,
	keyRing gomatrixserverlib.KeyRing,
	cache service.Cache,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

JoinRoomByIDOrAlias implements the "/join/{roomIDOrAlias}" API. https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-join-roomidoralias

func LegacyRegister

func LegacyRegister(
	ctx context.Context,
	req *external.LegacyRegisterRequest,
	accountDB model.AccountsDatabase,
	deviceDB model.DeviceDatabase,
	cfg *config.Dendrite,
	idg *uid.UidGenerator,
) (int, core.Coder)

LegacyRegister process register requests from the legacy v1 API

func LoginGet

func LoginGet(
	ctx context.Context,
	req *external.GetLoginRequest,
	accountDB model.AccountsDatabase,
	deviceDB model.DeviceDatabase,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	cfg config.Dendrite,
	admin bool,
	idg *uid.UidGenerator,
	tokenFilter *filter.Filter,
	rpcClient *common.RpcClient,
) (int, core.Coder)

func LoginPost

func LoginPost(
	ctx context.Context,
	req *external.PostLoginRequest,
	accountDB model.AccountsDatabase,
	deviceDB model.DeviceDatabase,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	cfg config.Dendrite,
	admin bool,
	idg *uid.UidGenerator,
	tokenFilter *filter.Filter,
	rpcClient *common.RpcClient,
) (int, core.Coder)

Login implements GET and POST /login

func Logout

func Logout(
	ctx context.Context,
	deviceDB model.DeviceDatabase,
	userID, deviceID string,
	cache service.Cache,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	tokenFilter *filter.Filter,
	rpcClient *common.RpcClient,
) (int, core.Coder)

Logout handles POST /logout

func LogoutAll

func LogoutAll(
	ctx context.Context,
	deviceDB model.DeviceDatabase,
	userID, deviceID string,
	cache service.Cache,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	tokenFilter *filter.Filter,
	rpcClient *common.RpcClient,
) (int, core.Coder)

LogoutAll handles POST /logout/all

func LogoutDevice

func LogoutDevice(
	ctx context.Context,
	userID,
	deviceID string,
	deviceDB model.DeviceDatabase,
	cache service.Cache,
	encryptDB model.EncryptorAPIDatabase,
	syncDB model.SyncAPIDatabase,
	tokenFilter *filter.Filter,
	rpcClient *common.RpcClient,
)

func OnAddServerNames

func OnAddServerNames(ctx context.Context, cache service.Cache, serverConfDB model.ConfigDatabase, serverNames []string, idg *uid.UidGenerator)

func OnDelServerNames

func OnDelServerNames(ctx context.Context, cache service.Cache, serverConfDB model.ConfigDatabase, serverNames []string)

current has not del

func OnGetServerNameCfg

func OnGetServerNameCfg(
	serverConfDB model.ConfigDatabase,
	cache service.Cache,
	cfg config.Dendrite,
) (int, core.Coder)

func OnRoomInfoRequest

func OnRoomInfoRequest(
	ctx context.Context,
	userID string,
	roomIDs []string,
	rpcCli roomserverapi.RoomserverRPCAPI,
	cache service.Cache,
) (int, core.Coder)

handle GET /rooms

func OnRoomJoinedRequest

func OnRoomJoinedRequest(
	ctx context.Context,
	userID,
	roomID string,
	rpcCli roomserverapi.RoomserverRPCAPI,
	cache service.Cache,
	complexCache *common.ComplexCache,
) (int, core.Coder)

handle GET /rooms/{roomId}/joined_members

func OnUpdateServerNameCfg

func OnUpdateServerNameCfg(
	ctx context.Context,
	req *external.ServerNameCfgRequest,
	serverConfDB model.ConfigDatabase,
	cache service.Cache,
	idg *uid.UidGenerator,
	cfg config.Dendrite,
) (int, core.Coder)

func PostEvent

func PostEvent(
	ctx context.Context,
	req *external.PutRoomStateByTypeWithTxnID,
	userID, deviceID, IP string,
	roomID, eventType string,
	txnID, stateKey *string,
	cfg config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,
	cache service.Cache,
	idg *uid.UidGenerator,
) (int, core.Coder)

func PutFilter

func PutFilter(
	ctx context.Context,
	filter *external.PostUserFilterRequest,
	userID string,
	accountDB model.AccountsDatabase,
	cache service.Cache,
) (int, core.Coder)

PutFilter implements POST /_matrix/client/r0/user/{userId}/filter

func QueryRoomInfo

func QueryRoomInfo(ctx context.Context, roomID string, rpcCli roomserverapi.RoomserverRPCAPI) (
	roomInfo *external.GetRoomInfo, err error)

func RedactEvent

func RedactEvent(
	ctx context.Context,

	content []byte,
	userID, deviceID string,
	roomID string,
	txnID, stateKey *string,
	cfg config.Dendrite,
	cache service.Cache,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
	redacts string,
	eventType string,
	idg *uid.UidGenerator,
) (int, core.Coder)

func RegisterAvailable

func RegisterAvailable() (int, core.Coder)

RegisterAvailable checks if the username is already taken or invalid.

func RemoveLocalAlias

func RemoveLocalAlias(
	ctx context.Context,
	userID string,
	alias string,
	rpcCli roomserverapi.RoomserverRPCAPI,
) (int, core.Coder)

RemoveLocalAlias implements DELETE /directory/room/{roomAlias} TODO: Check if the user has the power level to remove an alias

func RequestEmailToken

func RequestEmailToken() (int, core.Coder)

RequestEmailToken implements:

POST /account/3pid/email/requestToken
POST /register/email/requestToken

func RequestTurnServer

func RequestTurnServer(ctx context.Context, userID string, cfg config.Dendrite) (int, core.Coder)

RequestTurnServer implements:

GET /voip/turnServer

func SaveAccountData

func SaveAccountData(
	ctx context.Context,
	accountDB model.AccountsDatabase,
	deviceID string,
	cfg config.Dendrite,
	userID,
	roomID,
	dataType string,
	content []byte,
	cache service.Cache,
) (int, core.Coder)

handle /user/{userId}/[rooms/{roomId}/]account_data/{type} handle /user/{userID}/account_data/{type} with roomID empty

func SendMembership

func SendMembership(
	ctx context.Context, r *external.PostRoomsMembershipRequest, accountDB model.AccountsDatabase, userID string,
	deviceID, roomID, membership string, cfg config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,
	federation *fed.Federation,
	cache service.Cache,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

SendMembership implements PUT /rooms/{roomID}/(join|kick|ban|unban|leave|invite) by building a m.room.member event then sending it to the room server

func SetAvatarURL

func SetAvatarURL(
	ctx context.Context, r *external.PutAvatarURLRequest,
	accountDB model.AccountsDatabase,
	userID string, cfg *config.Dendrite,
	cache service.Cache,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

SetAvatarURL implements PUT /profile/{userID}/avatar_url

func SetDisplayName

func SetDisplayName(
	ctx context.Context, r *external.PutDisplayNameRequest,
	accountDB model.AccountsDatabase,
	userID string, cfg *config.Dendrite,
	cache service.Cache,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

SetDisplayName implements PUT /profile/{userID}/displayname

func SetLocalAlias

func SetLocalAlias(
	ctx context.Context,
	req *external.PutDirectoryRoomAliasRequest,
	userID string,
	alias string,
	cfg *config.Dendrite,
	rpcCli roomserverapi.RoomserverRPCAPI,
) (int, core.Coder)

SetLocalAlias implements PUT /directory/room/{roomAlias} TODO: Check if the user has the power level to set an alias

func SetRoomTag

func SetRoomTag(
	ctx context.Context,
	req *external.PutRoomsTagsByIDRequest,
	accountDB model.AccountsDatabase,
	userID string,
	cfg config.Dendrite,
) (int, core.Coder)

func SetUserInfo

func SetUserInfo(
	ctx context.Context, r *external.PutUserInfoRequest,
	accountDB model.AccountsDatabase,
	userID string, cfg *config.Dendrite,
	cache service.Cache,
	rsRpcCli roomserverapi.RoomserverRPCAPI,
	idg *uid.UidGenerator,
	complexCache *common.ComplexCache,
) (int, core.Coder)

SetUserInfo implements PUT /user_info/{userID}

func UpdateDeviceByID

func UpdateDeviceByID(
	ctx context.Context, r *external.PutDeviceRequest,
	deviceDB model.DeviceDatabase, userID, deviceID string,
	toDeviceID string, cache service.Cache,
) (int, core.Coder)

UpdateDeviceByID handles PUT on /devices/{deviceID}

func UpdatePresenceByID

func UpdatePresenceByID(
	ctx context.Context,
	reqContent *external.PutPresenceRequest,
	presenceDB model.PresenceDatabase,
	cfg *config.Dendrite,
	rpcCli *common.RpcClient,
	cache service.Cache,
	userID, deviceID string,
	complexCache *common.ComplexCache,
) (int, core.Coder)

func UpdatePresenceListByID

func UpdatePresenceListByID() (int, core.Coder)

func UsernameIsWithinApplicationServiceNamespace

func UsernameIsWithinApplicationServiceNamespace(
	cfg *config.Dendrite,
	username string,
	appService *config.ApplicationService,
) bool

UsernameIsWithinApplicationServiceNamespace checks to see if a username falls within any of the namespaces of a given Application Service. If no Application Service is given, it will check to see if it matches any Application Service's namespace.

func UsernameMatchesMultipleExclusiveNamespaces

func UsernameMatchesMultipleExclusiveNamespaces(
	cfg *config.Dendrite,
	username string,
) bool

UsernameMatchesMultipleExclusiveNamespaces will check if a given username matches more than one exclusive namespace. More than one is not allowed

Types

This section is empty.

Jump to

Keyboard shortcuts

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