(sub *types.Subscription, action int)
| 549 | } |
| 550 | |
| 551 | func 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 |
| 598 | func pluginMessage(data *MsgServerData, action int) { |
no test coverage detected
searching dependent graphs…