MCPcopy
hub / github.com/tinode/chat / pluginTopic

Function pluginTopic

server/plugins.go:516–549  ·  view source on GitHub ↗
(topic *Topic, action int)

Source from the content-addressed store, hash-verified

514}
515
516func pluginTopic(topic *Topic, action int) {
517 if globals.plugins == nil {
518 return
519 }
520
521 var event *pbx.TopicEvent
522 for i := range globals.plugins {
523 p := &globals.plugins[i]
524 if p.filterTopic == nil || p.filterTopic.byAction&action == 0 {
525 // Plugin is not interested in Message actions
526 continue
527 }
528
529 if event == nil {
530 event = &pbx.TopicEvent{
531 Action: pluginActionToCrud(action),
532 Name: topic.name,
533 Desc: pbTopicSerializeToDesc(topic),
534 }
535 }
536
537 var ctx context.Context
538 var cancel context.CancelFunc
539 if p.timeout > 0 {
540 ctx, cancel = context.WithTimeout(context.Background(), p.timeout)
541 defer cancel()
542 } else {
543 ctx = context.Background()
544 }
545 if _, err := p.client.Topic(ctx, event); err != nil {
546 logs.Warn.Println("plugins: Topic call failed", p.name, err)
547 }
548 }
549}
550
551func pluginSubscription(sub *types.Subscription, action int) {
552 if globals.plugins == nil {

Callers 4

topicUnregMethod · 0.85
registerSessionMethod · 0.85
handleMetaSetMethod · 0.85

Calls 4

pluginActionToCrudFunction · 0.85
pbTopicSerializeToDescFunction · 0.85
PrintlnMethod · 0.80
TopicMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…