personal

package
v1.0.52 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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"
)
View Source
const (
	StatusEnabled = "enabled"
	StatusPending = "pending"
)
View Source
const (
	StateFileName     = "personal_subscriptions.json"
	StateLockFileName = "personal_subscriptions.lock"
)
View Source
const DefaultBasePath = "/dws"

Variables

This section is empty.

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 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 PublicAvailabilityError

func PublicAvailabilityError(eventKey string) error

func RemoveRunStates

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

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"`
	Details   map[string]any `json:"details,omitempty"`
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	Identity   Identity
}

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"`
	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 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 RuleOptions

type RuleOptions struct {
	RuleType string
	UserID   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"`
	JQRootPath     string         `json:"jq_root_path"`
	Schema         map[string]any `json:"schema"`
}

func BuildSchemaDocument

func BuildSchemaDocument(def Definition) 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