Help us shape the future of Go! Take the 2026 Go Developer Survey

channelhttp

package
v1.150.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package channelhttp serves the portal's channel routes: the channels the signed-in person can reach with their bots' chat channels, sharing an asset to one from the Share dialog (#2241), and sending a message to one (#1723).

Every route is a notify tool call, made over an in-memory session that authenticates as the person the portal signed in. That is the whole point of the shape: who may reach a channel, what an asset becomes when it is posted, the per-session rate limit and the audit row are the tool's, so the asset page and an agent asking for the same post cannot come to disagree about any of them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SharingFor added in v1.149.0

func SharingFor(reg *persona.Registry, adminPersona string) func(*access.User) bool

SharingFor answers whether a portal user's persona lets them share (#2241): the persona their roles resolve to allows it, or is the admin persona. A user whose roles resolve to no persona shares nothing. nil with no registry, which allows everyone.

Types

type API

type API struct {
	// Server is the assembled MCP server the calls are made against. nil
	// answers every route 503.
	Server *mcp.Server
	// SharingAllowed reports whether the signed-in person's persona lets
	// them share (#2241). The channel list and the channel share refuse
	// without it. nil allows everyone.
	SharingAllowed func(*access.User) bool
}

API serves the routes.

func (*API) CallAs added in v1.150.0

func (a *API) CallAs(w http.ResponseWriter, r *http.Request, user *access.User, args map[string]any) bool

CallAs issues one notify call as user and writes what the tool answered, reporting whether the post went out: a file posted to a channel withdraws the share it made when it did not (#2258).

func (*API) Register

func (a *API) Register(mux *http.ServeMux)

Register mounts the routes on the portal's authenticated mux.

type ChannelShareRequest added in v1.149.0

type ChannelShareRequest struct {
	// Channel is the channel's name, as the list reports it.
	Channel string `json:"channel" example:"slack"`
	// Target is the chat channel of a slack or mattermost channel, one of
	// the ids the list reports under the channel's targets. Empty posts to
	// the channel's own.
	Target string `json:"target,omitempty" example:"C0123456789"`
	// AccessMode is who opens the posted link: authenticated (any signed-in
	// user, no expiration) or public (anyone with the link, expires_in
	// required).
	AccessMode string `json:"access_mode" example:"authenticated" enums:"authenticated,public"`
	// ExpiresIn is the public link's lifetime, a duration such as 168h.
	ExpiresIn string `json:"expires_in,omitempty" example:"168h"`
	// Message is an optional line posted above the asset.
	Message string `json:"message,omitempty" example:"This week's numbers"`
}

ChannelShareRequest shares an asset to a channel (#2241).

type SendRequest

type SendRequest struct {
	Title string `json:"title" example:"Nightly load finished late"`
	// Body is markdown.
	Body string `json:"body,omitempty" example:"The load finished at 06:40, forty minutes past its window."`
	// Link is the absolute URL a reader follows from the message.
	Link string `json:"link,omitempty" example:"https://platform.example.com/portal/automations/scr_1/runs/run_9"`
}

SendRequest posts a message.

Jump to

Keyboard shortcuts

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