(topic *Topic, action int)
| 514 | } |
| 515 | |
| 516 | func 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 | |
| 551 | func pluginSubscription(sub *types.Subscription, action int) { |
| 552 | if globals.plugins == nil { |
no test coverage detected
searching dependent graphs…