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

Function pluginSubscription

server/plugins.go:551–595  ·  view source on GitHub ↗
(sub *types.Subscription, action int)

Source from the content-addressed store, hash-verified

549}
550
551func pluginSubscription(sub *types.Subscription, action int) {
552 if globals.plugins == nil {
553 return
554 }
555
556 var event *pbx.SubscriptionEvent
557 for i := range globals.plugins {
558 p := &globals.plugins[i]
559 if p.filterSubscription == nil || p.filterSubscription.byAction&action == 0 {
560 // Plugin is not interested in Message actions
561 continue
562 }
563
564 if event == nil {
565 event = &pbx.SubscriptionEvent{
566 Action: pluginActionToCrud(action),
567 Topic: sub.Topic,
568 UserId: sub.User,
569
570 DelId: int32(sub.DelId),
571 ReadId: int32(sub.ReadSeqId),
572 RecvId: int32(sub.RecvSeqId),
573
574 Mode: &pbx.AccessMode{
575 Want: sub.ModeWant.String(),
576 Given: sub.ModeGiven.String(),
577 },
578
579 Private: interfaceToBytes(sub.Private),
580 }
581 }
582
583 var ctx context.Context
584 var cancel context.CancelFunc
585 if p.timeout > 0 {
586 ctx, cancel = context.WithTimeout(context.Background(), p.timeout)
587 defer cancel()
588 } else {
589 ctx = context.Background()
590 }
591 if _, err := p.client.Subscription(ctx, event); err != nil {
592 logs.Warn.Println("plugins: Subscription call failed", p.name, err)
593 }
594 }
595}
596
597// Message accepted for delivery
598func pluginMessage(data *MsgServerData, action int) {

Callers 5

topicUnregMethod · 0.85
thisUserSubMethod · 0.85
anotherUserSubMethod · 0.85
replyDelSubMethod · 0.85
replyLeaveUnsubMethod · 0.85

Calls 5

pluginActionToCrudFunction · 0.85
interfaceToBytesFunction · 0.85
PrintlnMethod · 0.80
SubscriptionMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…