handler

package
v0.99.36-0...-9dd75c3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Artistic-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package handler provides HTTP handlers for the Convos API. It includes utilities for managing user sessions, constructing absolute URLs, and handling errors in a consistent manner across the API endpoints. The Handler struct serves as a central point for accessing core application logic, embedding services, and session management.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequestNotFound        = errors.New("internal error: request not found in context")
	ErrResponseWriterNotFound = errors.New("internal error: response writer not found in context")
	ErrUnauthorized           = errors.New("unauthorized")
	ErrForbidden              = errors.New("forbidden")
	ErrInvalidInviteToken     = errors.New("invalid token. You have to ask your Convos admin for a new link")
)
View Source
var (
	ErrUploadFail     = errors.New("upload error")
	ErrUploadTooLarge = errors.New("file exceeds the maximum upload size")
)

Functions

func ParseWebhookNetworks

func ParseWebhookNetworks(s string) []*net.IPNet

ParseWebhookNetworks parses a comma-separated list of CIDR ranges.

Types

type Handler

type Handler struct {
	Core          *core.Core
	Authenticator core.Authenticator
	EmbedClient   *embed.Client
	I18n          *i18n.Catalog
	Store         sessions.Store
	WebhookNets   []*net.IPNet
	Bot           *bot.Manager
	MaxUploadSize int64
	InviteExpiry  time.Duration
}

func NewHandler

func NewHandler(c *core.Core, authenticator core.Authenticator, store sessions.Store, webhookNets []*net.IPNet) *Handler

func (*Handler) CheckForUpdates

CheckForUpdates implements api.StrictServerInterface. Fetches the latest version from convos.chat and compares with the running version.

func (*Handler) ConnectionMessages

ConnectionMessages implements api.StrictServerInterface.

func (*Handler) ConversationMessages

ConversationMessages implements api.StrictServerInterface.

func (*Handler) CreateConnection

CreateConnection implements api.StrictServerInterface.

func (*Handler) DeleteFiles

DeleteFiles implements api.StrictServerInterface.

func (*Handler) DeleteUser

DeleteUser implements api.StrictServerInterface.

func (*Handler) Embed

Embed implements api.StrictServerInterface. Fetches URL metadata (Open Graph, content-type) for link previews in chat.

func (*Handler) GetDictionary

GetDictionary implements api.StrictServerInterface. Returns translation dictionary for the requested language.

func (*Handler) GetFile

GetFile implements api.StrictServerInterface.

func (*Handler) GetFiles

GetFiles implements api.StrictServerInterface.

func (*Handler) GetSettings

GetSettings implements api.StrictServerInterface.

func (*Handler) GetUser

GetUser implements api.StrictServerInterface.

func (*Handler) GetUserFromCtx

func (h *Handler) GetUserFromCtx(ctx context.Context) *core.User

func (*Handler) GetUserFromSession

func (h *Handler) GetUserFromSession(r *http.Request) *core.User

func (*Handler) GetUsers

GetUsers implements api.StrictServerInterface.

func (*Handler) GetVapidKey

GetVapidKey handles GET /push/vapid

func (*Handler) InviteUser

InviteUser implements api.StrictServerInterface.

func (*Handler) ListConnectionProfiles

ListConnectionProfiles implements api.StrictServerInterface.

func (*Handler) ListConnections

ListConnections implements api.StrictServerInterface.

func (*Handler) ListConversations

ListConversations implements api.StrictServerInterface.

func (*Handler) LoginUser

LoginUser implements api.StrictServerInterface.

func (*Handler) LogoutUser

LogoutUser implements api.StrictServerInterface.

func (*Handler) MarkConnectionAsRead

MarkConnectionAsRead implements api.StrictServerInterface.

func (*Handler) MarkConversationAsRead

MarkConversationAsRead implements api.StrictServerInterface.

func (*Handler) MarkNotificationsAsRead

MarkNotificationsAsRead implements api.StrictServerInterface.

func (*Handler) NotificationMessages

NotificationMessages implements api.StrictServerInterface.

func (*Handler) OIDCCallbackHandler

func (h *Handler) OIDCCallbackHandler(w http.ResponseWriter, r *http.Request)

OIDCCallbackHandler handles the OAuth2 callback from the OIDC provider.

func (*Handler) OIDCLoginHandler

func (h *Handler) OIDCLoginHandler(w http.ResponseWriter, r *http.Request)

OIDCLoginHandler initiates the OIDC login flow.

func (*Handler) RegisterUser

RegisterUser implements api.StrictServerInterface.

func (*Handler) RemoveConnection

RemoveConnection implements api.StrictServerInterface.

func (*Handler) RemoveConnectionProfile

RemoveConnectionProfile implements api.StrictServerInterface.

func (*Handler) SaveConnectionProfile

SaveConnectionProfile implements api.StrictServerInterface.

func (*Handler) SearchMessages

SearchMessages implements api.StrictServerInterface.

func (*Handler) SubscribeToPush

SubscribeToPush handles POST /push/subscribe

func (*Handler) UnsubscribeFromPush

UnsubscribeFromPush handles POST /push/unsubscribe

func (*Handler) UpdateConnection

UpdateConnection implements api.StrictServerInterface.

func (*Handler) UpdateSettings

UpdateSettings implements api.StrictServerInterface.

func (*Handler) UpdateUser

UpdateUser implements api.StrictServerInterface.

func (*Handler) UploadFile

UploadFile implements api.StrictServerInterface.

func (*Handler) Webhook

Webhook implements api.StrictServerInterface. Validates the source IP and forwards webhook payloads as IRC messages.

Jump to

Keyboard shortcuts

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