Documentation
¶
Index ¶
- Constants
- func ActionNotifyProducerID(owner string) carddispatch.ProducerID
- func DocsApprovalCardsEnabled() bool
- func NewActionFinalizerFromContext(ctx *config.Context) (*cardactiondispatch.FinalizerRegistry, error)
- func NotifyBotUID() string
- type ApprovalCardAction
- type ApprovalCardFields
- type BatchNotifyReq
- type BatchNotifyResp
- type BatchNotifyResult
- type DocsActionFinalizer
- type DocsCardFields
- type Notify
- type NotifyReq
- type NotifyResp
- type StandardActionFinalizer
- type SummaryCardFields
Constants ¶
const ( SummaryCardKindCompleted = "completed" SummaryCardKindFailed = "failed" )
Card notification kinds.
const ( DocsCardKindCommented = "commented" DocsCardKindAccessRequested = "access_requested" DocsCardKindAccessGranted = "access_granted" DocsCardKindAccessDenied = "access_denied" )
Docs card notification kinds.
const InternalTokenHeader = "X-Internal-Token"
InternalTokenHeader is the header key for internal service authentication.
const (
// NotifyBotUIDValue is the static UID for the notification system bot.
NotifyBotUIDValue = "notification"
)
Variables ¶
This section is empty.
Functions ¶
func ActionNotifyProducerID ¶ added in v1.11.0
func ActionNotifyProducerID(owner string) carddispatch.ProducerID
ActionNotifyProducerID maps one route-bound owner to a stable internal producer without putting unbounded owner text into registry identifiers.
func DocsApprovalCardsEnabled ¶ added in v1.11.0
func DocsApprovalCardsEnabled() bool
DocsApprovalCardsEnabled exposes the rollout decision to the composition root so producer capability and callback routing fail closed together.
func NewActionFinalizerFromContext ¶ added in v1.11.0
func NewActionFinalizerFromContext(ctx *config.Context) (*cardactiondispatch.FinalizerRegistry, error)
NewActionFinalizerFromContext composes the standard approval fallback with the docs-specific visual. New standard consumers require no code binding.
func NotifyBotUID ¶
func NotifyBotUID() string
NotifyBotUID returns the static notification bot UID.
Types ¶
type ApprovalCardAction ¶ added in v1.11.0
ApprovalCardAction lets the caller name a bounded, custom button on the generic approval card. Server owns the action ID and reserved metadata.
type ApprovalCardFields ¶ added in v1.11.0
type ApprovalCardFields struct {
ActionType string `json:"action_type"`
Title string `json:"title"`
Description string `json:"description"`
Data map[string]string `json:"data"`
// Actions is optional. When omitted, octo-server renders the localized
// approve/deny buttons (byte-compatible with the pre-http-actions release).
// When present, it must contain 1..MaxApprovalCustomActions items; each
// decision is a stable callback token and each title is display text.
Actions []ApprovalCardAction `json:"actions,omitempty"`
}
type BatchNotifyReq ¶
type BatchNotifyReq struct {
Notifications []NotifyReq `json:"notifications" binding:"required"`
}
BatchNotifyReq 批量通知请求
type BatchNotifyResp ¶
type BatchNotifyResp struct {
Results []BatchNotifyResult `json:"results"`
HasErrors bool `json:"has_errors"`
}
BatchNotifyResp 批量通知响应
type BatchNotifyResult ¶
type BatchNotifyResult struct {
NotifyResp
Error string `json:"error,omitempty"`
}
BatchNotifyResult 批量通知中单条结果
type DocsActionFinalizer ¶ added in v1.11.0
type DocsActionFinalizer struct {
// contains filtered or unexported fields
}
func NewDocsActionFinalizer ¶ added in v1.11.0
func NewDocsActionFinalizer(ctx *config.Context, mutator cardActionMutator, sender carddispatch.Sender) (*DocsActionFinalizer, error)
func NewDocsActionFinalizerFromContext ¶ added in v1.11.0
func NewDocsActionFinalizerFromContext(ctx *config.Context) (*DocsActionFinalizer, error)
func (*DocsActionFinalizer) Finalize ¶ added in v1.11.0
func (f *DocsActionFinalizer) Finalize(ctx context.Context, event cardactiondispatch.Event, result cardactiondispatch.DecisionResult) error
type DocsCardFields ¶ added in v1.10.0
type DocsCardFields struct {
DocID string `json:"doc_id"` // maps to /d/{doc_id}?sp={space_id}
RequestID string `json:"request_id"` // required by access_requested v2; docs domain idempotency/CAS key
Kind string `json:"kind"` // "shared" | "commented" | "access_requested"
Title string `json:"title"` // document title
ActorName string `json:"actor_name"` // pre-resolved actor display name; empty allowed
// ActorAvatarURL is an optional absolute https avatar for the requester,
// surfaced on the access-request approval card. Additive & backward
// compatible: empty (or omitted) renders no avatar; a non-https value fails
// the card build (same positive allowlist as any rendered image URL). The
// docs backend owns population; octo-server does not resolve it.
ActorAvatarURL string `json:"actor_avatar_url"`
Excerpt string `json:"excerpt"` // optional preview / comment / access reason
UpdatedAt string `json:"updated_at"` // pre-formatted timestamp; empty allowed
}
DocsCardFields is the docs-notify structured card input (cross-repo contract, see .octospec/tasks/card-message-internal-dispatch/docs-notify-contract.md). Fields carry raw values only; attribution/label copy, layout, and the /d/{doc_id}?sp={space_id} deep-link are owned by the server (pkg/cardtmpl + modules/notify.buildDocsCard + i18n.OutboundLanguage). The docs backend pre-formats display strings it wants surfaced verbatim (ActorName, UpdatedAt) so octo-server does not resolve secondary identities on the card path.
type Notify ¶
Notify 通知模块
type NotifyReq ¶
type NotifyReq struct {
SpaceID string `json:"space_id" binding:"required"`
Service string `json:"service" binding:"required"`
Event string `json:"event"`
Targets []string `json:"targets" binding:"required"`
ActorUID string `json:"actor_uid"`
Payload map[string]interface{} `json:"payload"`
Card *SummaryCardFields `json:"card"`
DocsCard *DocsCardFields `json:"docs_card"`
ApprovalCard *ApprovalCardFields `json:"approval_card"`
}
NotifyReq 通知请求
Payload / Card / DocsCard / ApprovalCard 四选一:
- 文本通知(现状):填 Payload{type:1,content:...},另两者省略。
- 智能总结卡片(summary-notify pilot):填结构化 Card,另两者省略。服务端用 pkg/cardtmpl 生成 octo/v1 卡片,经 internal/carddispatch 派发。
- 文档通知卡片(docs-notify):填结构化 DocsCard,另两者省略。
- 通用审批卡片:填结构化 ApprovalCard;owner 由路由绑定的独立 token 决定,调用方只提供 action_type 和有界业务标识。
调用方永不构造 type-17 map(Decision 14 仍拒绝 payload 里的 card 形状)。
type NotifyResp ¶
type NotifyResp struct {
Delivered []string `json:"delivered"`
Filtered map[string]string `json:"filtered"`
}
NotifyResp 单条通知响应
type StandardActionFinalizer ¶ added in v1.11.0
type StandardActionFinalizer struct {
// contains filtered or unexported fields
}
func NewStandardActionFinalizer ¶ added in v1.11.0
func NewStandardActionFinalizer(mutator cardActionMutator, sender carddispatch.Sender) (*StandardActionFinalizer, error)
func (*StandardActionFinalizer) Finalize ¶ added in v1.11.0
func (f *StandardActionFinalizer) Finalize(ctx context.Context, event cardactiondispatch.Event, result cardactiondispatch.DecisionResult) error
type SummaryCardFields ¶ added in v1.10.0
type SummaryCardFields struct {
TaskNo string `json:"task_no"` // summary_task.task_no,用于 /s/{task_no}?sp={space_id}
Kind string `json:"kind"` // "completed" | "failed"
Title string `json:"title"` // 总结标题(服务端转义/截断)
TimeRange string `json:"time_range"` // 已格式化的时间范围;空则省略
Members int `json:"members"` // 参与人数;<=0 省略
MsgCount int `json:"msg_count"` // 消息条数;<=0 省略
GeneratedAt string `json:"generated_at"` // 已格式化的生成时间;空则省略
Reason string `json:"reason"` // failed 的脱敏原因;completed 留空
}
SummaryCardFields 是 summary-notify 卡片通知的结构化入参(跨仓契约,见 .octospec/tasks/card-message-internal-dispatch/summary-notify-contract.md)。 只承载原始字段;文案标签、布局、deep-link 由服务端 pkg/cardtmpl + i18n.OutboundLanguage 生成。时间字段由调用方按其时区格式化后传字符串,计数传整数。