personal

package
v1.0.58 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// AttemptStateFileName stores retry suppression state for personal
	// subscription creation. It intentionally does not share the successful
	// subscription run-state file.
	AttemptStateFileName = "personal_subscription_attempts.json"
	// AttemptStateLockFileName serializes cross-process attempt-state changes.
	AttemptStateLockFileName = "personal_subscription_attempts.lock"
)
View Source
const (
	EventMention                      = "user_im_message_receive_at"
	EventSingleChat                   = "user_im_message_receive_o2o"
	EventInChat                       = "user_im_message_receive_group"
	EventFromUser                     = "user_im_message_receive_user"
	EventAllSingleChat                = "user_im_message_receive_o2o_all"
	EventAllGroupChat                 = "user_im_message_receive_group_all"
	EventReadO2O                      = "user_im_message_read_o2o"
	EventReadGroup                    = "user_im_message_read_group"
	EventRecallO2O                    = "user_im_message_recall_o2o"
	EventRecallGroup                  = "user_im_message_recall_group"
	EventReactionO2O                  = "user_im_message_reaction_o2o"
	EventReactionGroup                = "user_im_message_reaction_group"
	EventGroupUpdated                 = "user_im_group_updated"
	EventGroupMemberAdded             = "user_im_group_member_added"
	EventGroupMemberExited            = "user_im_group_member_exited"
	EventGroupDisbanded               = "user_im_group_disbanded"
	EventOAApprovalTaskCreated        = "user_oa_approval_task_created"
	EventOAApprovalTaskFinished       = "user_oa_approval_task_finished"
	EventOAApprovalTaskRedirected     = "user_oa_approval_task_redirected"
	EventOAApprovalInstanceStarted    = "user_oa_approval_instance_started"
	EventOAApprovalInstanceTerminated = "user_oa_approval_instance_terminated"
	EventOAApprovalInstanceFinished   = "user_oa_approval_instance_finished"
)
View Source
const (
	StatusEnabled = "enabled"
	StatusPending = "pending"
)
View Source
const (
	StateFileName     = "personal_subscriptions.json"
	StateLockFileName = "personal_subscriptions.lock"
)
View Source
const DefaultBasePath = "/dws"

Variables

View Source
var (
	// ErrAttemptClaimStale means another process replaced at least one claimed
	// fingerprint. Completion is rejected as a unit so an old process cannot
	// overwrite newer state.
	ErrAttemptClaimStale = errors.New("personal event: subscription attempt claim is stale")
)

Functions

func BuildFilter

func BuildFilter(filterJSON string, queryCSV string) (any, string, error)

func BuildRuleParam

func BuildRuleParam(eventKey string, opts RuleOptions) (ruleType string, ruleParam map[string]any, err error)

func CanonicalJSON

func CanonicalJSON(v any) (string, error)

func Fingerprint added in v1.0.56

func Fingerprint(endpoint, idempotencyKey string, profileSelector ...string) string

Fingerprint hashes an endpoint, the existing subscription idempotency key, and optional profile selectors into a stable non-reversible store key. Passing the active selector ensures two profiles resolving to the same corp/user can recover independently after a profile change.

func IdempotencyKey

func IdempotencyKey(identity Identity, eventKey, ruleType string, ruleParam map[string]any, filterCanonical string) string

func IsPublic

func IsPublic(eventKey string) bool

func IsSchemaPending

func IsSchemaPending(err error) bool

func ProjectOutput added in v1.0.54

func ProjectOutput(ev transport.Event) (any, error)

ProjectOutput converts the transport envelope into the stable personal event output. On malformed Data it returns the original envelope together with an error; the formatter logs the warning and still emits that envelope.

func PublicAvailabilityError

func PublicAvailabilityError(eventKey string) error

func RemoveRunStates

func RemoveRunStates(workDir string, subscribeIDs []string) error

func SupportsMessageFilter added in v1.0.55

func SupportsMessageFilter(eventKey string) bool

SupportsMessageFilter reports whether --query/--filter-json describe a stable message payload for this event. Action and group lifecycle events do not expose the same filter fields.

func UpsertRunState

func UpsertRunState(workDir string, st RunState) error

Types

type APIError

type APIError struct {
	Code              string         `json:"code"`
	Message           string         `json:"message"`
	Retryable         *bool          `json:"retryable,omitempty"`
	RetryAfterSeconds *int64         `json:"retry_after_seconds,omitempty"`
	NextRetryAt       *time.Time     `json:"next_retry_at,omitempty"`
	TraceID           string         `json:"trace_id,omitempty"`
	HTTPStatus        int            `json:"http_status,omitempty"`
	Details           map[string]any `json:"details,omitempty"`
}

func (*APIError) Error

func (e *APIError) Error() string

type AttemptBlockedError added in v1.0.56

type AttemptBlockedError struct {
	Fingerprint   string
	EventKey      string
	State         AttemptState
	Retryability  Retryability
	RetryAfter    time.Duration
	NextAllowedAt time.Time
	FailureCount  int
	ErrorCode     string
	TraceID       string
}

AttemptBlockedError reports a local suppression decision. It never includes the raw endpoint, idempotency key, profile selector, rule parameter, or filter.

func (*AttemptBlockedError) Error added in v1.0.56

func (e *AttemptBlockedError) Error() string

type AttemptClaim added in v1.0.56

type AttemptClaim struct {
	AttemptID    string
	Fingerprints []string
	// contains filtered or unexported fields
}

AttemptClaim is the ownership token returned by Claim. Callers must finish it with CompleteSuccess, CompleteFailure, or Release.

type AttemptFailure added in v1.0.56

type AttemptFailure struct {
	Fingerprint  string
	Retryability Retryability
	RetryAfter   time.Duration
	ErrorCode    string
	TraceID      string
}

AttemptFailure describes the one failed item in a claimed batch.

type AttemptHold added in v1.0.56

type AttemptHold struct {
	Fingerprint   string
	State         AttemptState
	Retryability  Retryability
	RetryAfter    time.Duration
	NextAllowedAt time.Time
	FailureCount  int
}

AttemptHold is the persisted suppression decision after CompleteFailure.

type AttemptSpec added in v1.0.56

type AttemptSpec struct {
	Fingerprint string
	EventKey    string
}

AttemptSpec identifies one normalized subscription request. Fingerprint must come from Fingerprint; only the digest and the non-sensitive event key are persisted.

type AttemptState added in v1.0.56

type AttemptState string

AttemptState is the persisted lifecycle state of one subscription attempt.

const (
	AttemptStateInFlight     AttemptState = "in_flight"
	AttemptStateCooldown     AttemptState = "cooldown"
	AttemptStateTerminalHold AttemptState = "terminal_hold"
)

type AttemptStore added in v1.0.56

type AttemptStore struct {
	// contains filtered or unexported fields
}

AttemptStore coordinates personal subscription creation across CLI processes sharing one identity work directory.

func NewAttemptStore added in v1.0.56

func NewAttemptStore(workDir string, options ...AttemptStoreOption) *AttemptStore

NewAttemptStore creates a fail-closed persistent attempt guard rooted in the identity-specific personal event work directory.

func (*AttemptStore) Claim added in v1.0.56

func (s *AttemptStore) Claim(specs []AttemptSpec, lease time.Duration) (*AttemptClaim, error)

Claim atomically reserves every fingerprint in specs. If any fingerprint is still suppressed, none are reserved and an AttemptBlockedError is returned.

func (*AttemptStore) CompleteFailure added in v1.0.56

func (s *AttemptStore) CompleteFailure(
	claim *AttemptClaim,
	succeeded []string,
	failure AttemptFailure,
) (AttemptHold, error)

CompleteFailure records the failed item, clears successfully completed items, and restores every unexecuted item to its exact pre-claim state.

func (*AttemptStore) CompleteSuccess added in v1.0.56

func (s *AttemptStore) CompleteSuccess(claim *AttemptClaim) error

CompleteSuccess clears failure history for every item in a successful claimed batch.

func (*AttemptStore) Release added in v1.0.56

func (s *AttemptStore) Release(claim *AttemptClaim) error

Release restores every claimed item without recording a remote failure. It is intended for local failures before a subscription request is sent.

type AttemptStoreOption added in v1.0.56

type AttemptStoreOption func(*AttemptStore)

AttemptStoreOption customizes an AttemptStore.

func WithAttemptClock added in v1.0.56

func WithAttemptClock(now func() time.Time) AttemptStoreOption

WithAttemptClock installs a clock, primarily for deterministic tests.

func WithAttemptIDGenerator added in v1.0.56

func WithAttemptIDGenerator(generate func() (string, error)) AttemptStoreOption

WithAttemptIDGenerator installs an attempt-ID generator. IDs are persisted only as CAS tokens and must not contain request data.

type Client

type Client struct {
	BaseURL             string
	HTTPClient          *http.Client
	Identity            Identity
	AccessTokenProvider func(context.Context) (string, error)
	ClientVersion       string
	UserAgent           string
}

func NewClient

func NewClient(baseURL string, identity Identity) *Client

func (*Client) CreateSubscription

func (c *Client) CreateSubscription(ctx context.Context, req CreateSubscriptionRequest) (*Subscription, error)

func (*Client) DeleteSubscription

func (c *Client) DeleteSubscription(ctx context.Context, subscribeID string) error

func (*Client) GetSubscription

func (c *Client) GetSubscription(ctx context.Context, subscribeID string) (*Subscription, error)

func (*Client) ListSubscriptions

func (c *Client) ListSubscriptions(ctx context.Context, opts ListOptions) ([]Subscription, error)

type CreateSubscriptionRequest

type CreateSubscriptionRequest struct {
	EventKey       string         `json:"event_key"`
	RuleType       string         `json:"rule_type"`
	Name           string         `json:"name,omitempty"`
	RuleParam      map[string]any `json:"rule_param"`
	Filter         any            `json:"filter,omitempty"`
	Delivery       map[string]any `json:"delivery"`
	TTLSeconds     int64          `json:"ttl_seconds,omitempty"`
	IdempotencyKey string         `json:"idempotency_key,omitempty"`
}

type Definition

type Definition struct {
	EventKey       string                `json:"event_key"`
	DisplayName    string                `json:"display_name"`
	Description    string                `json:"description"`
	Category       string                `json:"category"`
	RuleType       string                `json:"rule_type"`
	Status         string                `json:"status"`
	RequiredParams []string              `json:"required_params"`
	Constraints    *ParameterConstraints `json:"constraints,omitempty"`
	Auth           map[string]any        `json:"auth,omitempty"`
	Public         bool                  `json:"-"`
}

func Catalog

func Catalog(category string, enabledOnly, includePending bool) []Definition

func Definitions

func Definitions() []Definition

func Lookup

func Lookup(eventKey string) (Definition, bool)

type GroupLifecycleEventOutput added in v1.0.55

type GroupLifecycleEventOutput struct {
	Type        string         `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID     string         `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp   int64          `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID string         `json:"subscribe_id" description:"订阅 ID"`
	Payload     map[string]any `` /* 130-byte string literal not displayed */
}

GroupLifecycleEventOutput is intentionally conservative until stable group event payload samples are available. Payload keeps unknown business fields while transport identity and routing metadata remain available only in raw output.

type GroupMemberEventMember added in v1.0.55

type GroupMemberEventMember struct {
	Nick           string `json:"nick" description:"成员展示名"`
	OpenDingTalkID string `json:"open_dingtalk_id" description:"成员开放 ID" format:"open_dingtalk_id"`
}

type GroupMemberEventOutput added in v1.0.55

type GroupMemberEventOutput struct {
	Type                   string                   `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID                string                   `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp              int64                    `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID            string                   `json:"subscribe_id" description:"订阅 ID"`
	ConversationID         string                   `json:"conversation_id" description:"发生成员变更的群会话 ID" format:"open_conversation_id"`
	Operator               string                   `json:"operator" description:"执行成员变更操作的用户展示名,系统操作或成员自行退出时可能为空"`
	OperatorOpenDingTalkID string                   `` /* 166-byte string literal not displayed */
	Members                []GroupMemberEventMember `json:"members" description:"本次加入或退出的成员列表"`
	EventTime              int64                    `json:"event_time" description:"群成员变更事件时间戳" format:"timestamp_ms"`
}

type Identity

type Identity struct {
	AccessToken  string `json:"-"`
	LocalSubject string `json:"-"`
	CorpID       string `json:"corp_id"`
	UserID       string `json:"user_id"`
	ClientID     string `json:"client_id"`
	SourceID     string `json:"source_id"`
}

func (Identity) Key

func (i Identity) Key() string

type ListOptions

type ListOptions struct {
	Status      string
	EventKey    string
	SubscribeID string
}

type MessageEventContext added in v1.0.55

type MessageEventContext struct {
	MessageID            string `json:"message_id" description:"内部消息的开放消息 ID" format:"open_message_id"`
	ConversationID       string `json:"conversation_id" description:"内部消息原来所在的会话 ID" format:"open_conversation_id"`
	Sender               string `json:"sender" description:"内部消息发送人展示名;服务端未提供时可能为空或为 null 字符串"`
	SenderOpenDingTalkID string `` /* 131-byte string literal not displayed */
	Content              string `json:"content" description:"内部消息正文;媒体消息可能包含 mediaId 等下载定位信息"`
	CreateTime           string `json:"create_time" description:"内部消息创建时间"`
}

MessageEventContext preserves the business context nested under a quoted reply or merged-forward message. Keep these fields structured instead of parsing the localized outer content summary.

type MessageEventOutput added in v1.0.54

type MessageEventOutput struct {
	Type                 string                `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID              string                `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp            int64                 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID          string                `json:"subscribe_id" description:"订阅 ID"`
	MessageID            string                `json:"message_id" description:"开放消息 ID" format:"open_message_id"`
	ConversationID       string                `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
	Sender               string                `json:"sender" description:"发送人展示名"`
	SenderOpenDingTalkID string                `json:"sender_open_dingtalk_id" description:"发送人开放 ID" format:"open_dingtalk_id"`
	Content              string                `json:"content" description:"消息正文"`
	CreateTime           string                `json:"create_time" description:"消息创建时间"`
	EventTime            int64                 `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
	QuotedMessage        *MessageEventContext  `json:"quoted_message,omitempty" description:"引用回复所引用的原消息;非引用回复时不输出"`
	ForwardMessages      []MessageEventContext `json:"forward_messages,omitempty" description:"合并转发包含的原消息列表;非合并转发时不输出"`
}

MessageEventOutput is the stable business-facing output for personal message receive events. Schema output is generated from these tags so the documented fields cannot drift from the values written by consume.

type OAApprovalInstanceFinishedOutput added in v1.0.58

type OAApprovalInstanceFinishedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"审批实例状态"`
	Result            string `json:"result" description:"审批实例处理结果,值以服务端实际推送为准"`
	CreateTime        int64  `json:"create_time" description:"审批实例创建时间" format:"timestamp_ms"`
	FinishTime        int64  `json:"finish_time" description:"审批实例完成时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批实例事件业务时间" format:"timestamp_ms"`
}

type OAApprovalInstanceStartedOutput added in v1.0.58

type OAApprovalInstanceStartedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"审批实例状态"`
	CreateTime        int64  `json:"create_time" description:"审批实例创建时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批实例事件业务时间" format:"timestamp_ms"`
}

type OAApprovalInstanceTerminatedOutput added in v1.0.58

type OAApprovalInstanceTerminatedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"审批实例状态"`
	CreateTime        int64  `json:"create_time" description:"审批实例创建时间" format:"timestamp_ms"`
	FinishTime        int64  `json:"finish_time" description:"审批实例终止时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批实例终止事件业务时间" format:"timestamp_ms"`
}

type OAApprovalTaskCreatedOutput added in v1.0.58

type OAApprovalTaskCreatedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	TaskID            string `json:"task_id" description:"审批任务 ID"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"审批任务状态"`
	CreateTime        int64  `json:"create_time" description:"审批任务创建时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批任务事件业务时间" format:"timestamp_ms"`
}

type OAApprovalTaskFinishedOutput added in v1.0.58

type OAApprovalTaskFinishedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	TaskID            string `json:"task_id" description:"审批任务 ID"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"审批任务状态"`
	Result            string `json:"result" description:"审批任务处理结果,值以服务端实际推送为准"`
	CreateTime        int64  `json:"create_time" description:"审批任务创建时间" format:"timestamp_ms"`
	FinishTime        int64  `json:"finish_time" description:"审批任务完成时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批任务事件业务时间" format:"timestamp_ms"`
}

type OAApprovalTaskRedirectedOutput added in v1.0.58

type OAApprovalTaskRedirectedOutput struct {
	Type              string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID           string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp         int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID       string `json:"subscribe_id" description:"订阅 ID"`
	ProcessInstanceID string `json:"process_instance_id" description:"审批实例 ID"`
	ProcessCode       string `json:"process_code" description:"审批流程模板编码"`
	TaskID            string `json:"task_id" description:"原审批任务 ID"`
	Title             string `json:"title" description:"审批标题"`
	Status            string `json:"status" description:"原审批任务状态"`
	Result            string `json:"result" description:"审批任务转交结果,值以服务端实际推送为准"`
	CreateTime        int64  `json:"create_time" description:"原审批任务创建时间" format:"timestamp_ms"`
	FinishTime        int64  `json:"finish_time" description:"原审批任务转交完成时间" format:"timestamp_ms"`
	EventTime         int64  `json:"event_time" description:"审批任务转交事件业务时间" format:"timestamp_ms"`
}

type ParameterConstraints added in v1.0.54

type ParameterConstraints struct {
	RequireOneOf      [][]string `json:"require_one_of,omitempty"`
	MutuallyExclusive [][]string `json:"mutually_exclusive,omitempty"`
}

type ReactionEventOutput added in v1.0.54

type ReactionEventOutput struct {
	Type                   string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID                string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp              int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID            string `json:"subscribe_id" description:"订阅 ID"`
	MessageID              string `json:"message_id" description:"收到表情回应的开放消息 ID" format:"open_message_id"`
	ConversationID         string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
	Operator               string `json:"operator" description:"执行表情回应操作的用户展示名"`
	OperatorOpenDingTalkID string `json:"operator_open_dingtalk_id" description:"执行表情回应操作的用户开放 ID" format:"open_dingtalk_id"`
	ReactionName           string `json:"reaction_name" description:"表情回应名称"`
	ReactionText           string `json:"reaction_text" description:"表情回应文本"`
	OperationType          string `json:"operation_type" description:"表情回应操作类型"`
	OperationTime          string `json:"operation_time" description:"表情回应操作时间"`
	Sender                 string `json:"sender" description:"原消息发送人展示名"`
	SenderOpenDingTalkID   string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
	EventTime              int64  `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}

type ReadEventOutput added in v1.0.54

type ReadEventOutput struct {
	Type                 string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID              string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp            int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID          string `json:"subscribe_id" description:"订阅 ID"`
	MessageID            string `json:"message_id" description:"被读取消息的开放消息 ID" format:"open_message_id"`
	ConversationID       string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
	Reader               string `json:"reader" description:"读取消息的用户展示名"`
	ReaderOpenDingTalkID string `json:"reader_open_dingtalk_id" description:"读取消息的用户开放 ID" format:"open_dingtalk_id"`
	Sender               string `json:"sender" description:"原消息发送人展示名"`
	SenderOpenDingTalkID string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
	ReadTime             string `json:"read_time" description:"消息读取时间"`
	EventTime            int64  `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}

type RecallEventOutput added in v1.0.54

type RecallEventOutput struct {
	Type                   string `json:"type" description:"事件类型,固定为当前 event_key"`
	EventID                string `json:"event_id" description:"事件 ID,可用于去重"`
	Timestamp              int64  `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
	SubscribeID            string `json:"subscribe_id" description:"订阅 ID"`
	MessageID              string `json:"message_id" description:"被撤回消息的开放消息 ID" format:"open_message_id"`
	ConversationID         string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
	Recaller               string `json:"recaller" description:"撤回消息的用户展示名"`
	RecallerOpenDingTalkID string `json:"recaller_open_dingtalk_id" description:"撤回消息的用户开放 ID" format:"open_dingtalk_id"`
	Sender                 string `json:"sender" description:"原消息发送人展示名"`
	SenderOpenDingTalkID   string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
	RecallTime             string `json:"recall_time" description:"消息撤回时间"`
	EventTime              int64  `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}

type Retryability added in v1.0.56

type Retryability string

Retryability preserves the distinction between an explicit server decision and an error for which the server did not provide retry guidance.

const (
	RetryabilityUnknown      Retryability = "unknown"
	RetryabilityRetryable    Retryability = "retryable"
	RetryabilityNonRetryable Retryability = "non_retryable"
)

func (Retryability) Value added in v1.0.56

func (r Retryability) Value() (value bool, known bool)

Value converts retryability to a bool while preserving whether it is known.

type RuleOptions

type RuleOptions struct {
	RuleType       string
	UserID         string
	OpenDingTalkID string
	GroupID        string
}

type RunState

type RunState struct {
	SubscribeID  string    `json:"subscribe_id"`
	EventKey     string    `json:"event_key,omitempty"`
	RuleType     string    `json:"rule_type,omitempty"`
	ClientID     string    `json:"client_id,omitempty"`
	SourceID     string    `json:"source_id,omitempty"`
	IdentityHash string    `json:"identity_hash,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
}

func LoadRunStates

func LoadRunStates(workDir string) ([]RunState, error)

type SchemaDocument

type SchemaDocument struct {
	EventKey       string                `json:"event_key"`
	DisplayName    string                `json:"display_name"`
	Description    string                `json:"description"`
	Category       string                `json:"category"`
	RuleType       string                `json:"rule_type"`
	RequiredParams []string              `json:"required_params"`
	Constraints    *ParameterConstraints `json:"constraints,omitempty"`
	JQRootPath     string                `json:"jq_root_path"`
	Schema         map[string]any        `json:"schema"`
}

func BuildSchemaDocument

func BuildSchemaDocument(def Definition) SchemaDocument

func BuildSchemaDocumentForMode added in v1.0.54

func BuildSchemaDocumentForMode(def Definition, flatten bool) SchemaDocument

type SchemaPendingError

type SchemaPendingError struct {
	EventKey string
}

func (*SchemaPendingError) Error

func (e *SchemaPendingError) Error() string

type Subscription

type Subscription struct {
	SubscribeID string     `json:"subscribe_id"`
	EventKey    string     `json:"event_key,omitempty"`
	RuleType    string     `json:"rule_type,omitempty"`
	Status      string     `json:"status,omitempty"`
	SourceID    string     `json:"source_id,omitempty"`
	CreatedAt   string     `json:"created_at,omitempty"`
	ExpiresAt   *time.Time `json:"expires_at,omitempty"`
}

Jump to

Keyboard shortcuts

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