MCPcopy
hub / github.com/larksuite/cli / FetchSubscribedCallbacks

Function FetchSubscribedCallbacks

internal/appmeta/app_callbacks.go:18–47  ·  view source on GitHub ↗

FetchSubscribedCallbacks returns the app's currently subscribed callback names from application/get. On a successful fetch it always returns a non-nil slice (empty when callback_info is absent or lists no callbacks) so callers can distinguish "fetched, zero callbacks subscribed" — a definitive conso

(ctx context.Context, client APIClient, appID string)

Source from the content-addressed store, hash-verified

16// that must fail the precheck — from a fetch error (nil), which is a
17// weak-dependency skip. Identity must be bot: the endpoint is app-level.
18func FetchSubscribedCallbacks(ctx context.Context, client APIClient, appID string) ([]string, error) {
19 path := fmt.Sprintf("/open-apis/application/v6/applications/%s?lang=zh_cn", appID)
20 raw, err := client.CallAPI(ctx, "GET", path, nil)
21 if err != nil {
22 return nil, err
23 }
24
25 var envelope struct {
26 Data struct {
27 App struct {
28 CallbackInfo *struct {
29 SubscribedCallbacks []string `json:"subscribed_callbacks"`
30 } `json:"callback_info"`
31 } `json:"app"`
32 } `json:"data"`
33 }
34 if err := json.Unmarshal(raw, &envelope); err != nil {
35 return nil, fmt.Errorf("decode application response: %w", err)
36 }
37 // callback_info also carries callback_type (e.g. "websocket"); it is
38 // intentionally not parsed or validated. Feishu open-platform callbacks are
39 // delivered over WebSocket only (confirmed), matching the CLI's WebSocket
40 // event source, so subscribed_callbacks alone is sufficient for the precheck.
41 // Revisit and validate callback_type if non-WebSocket delivery ever appears.
42 callbacks := []string{}
43 if ci := envelope.Data.App.CallbackInfo; ci != nil {
44 callbacks = append(callbacks, ci.SubscribedCallbacks...)
45 }
46 return callbacks, nil
47}

Calls 1

CallAPIMethod · 0.65