(user *types.User, action int)
| 474 | } |
| 475 | |
| 476 | func pluginAccount(user *types.User, action int) { |
| 477 | if globals.plugins == nil { |
| 478 | return |
| 479 | } |
| 480 | |
| 481 | var event *pbx.AccountEvent |
| 482 | for i := range globals.plugins { |
| 483 | p := &globals.plugins[i] |
| 484 | if p.filterAccount == nil || p.filterAccount.byAction&action == 0 { |
| 485 | // Plugin is not interested in Account actions |
| 486 | continue |
| 487 | } |
| 488 | |
| 489 | if event == nil { |
| 490 | event = &pbx.AccountEvent{ |
| 491 | Action: pluginActionToCrud(action), |
| 492 | UserId: user.Uid().UserId(), |
| 493 | DefaultAcs: pbDefaultAcsSerialize(&MsgDefaultAcsMode{ |
| 494 | Auth: user.Access.Auth.String(), |
| 495 | Anon: user.Access.Anon.String(), |
| 496 | }), |
| 497 | Public: interfaceToBytes(user.Public), |
| 498 | Tags: user.Tags, |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | var ctx context.Context |
| 503 | var cancel context.CancelFunc |
| 504 | if p.timeout > 0 { |
| 505 | ctx, cancel = context.WithTimeout(context.Background(), p.timeout) |
| 506 | defer cancel() |
| 507 | } else { |
| 508 | ctx = context.Background() |
| 509 | } |
| 510 | if _, err := p.client.Account(ctx, event); err != nil { |
| 511 | logs.Warn.Println("plugins: Account call failed", p.name, err) |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | func pluginTopic(topic *Topic, action int) { |
| 517 | if globals.plugins == nil { |
no test coverage detected
searching dependent graphs…