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

Function pluginAccount

server/plugins.go:476–514  ·  view source on GitHub ↗
(user *types.User, action int)

Source from the content-addressed store, hash-verified

474}
475
476func 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
516func pluginTopic(topic *Topic, action int) {
517 if globals.plugins == nil {

Callers 2

replyCreateUserFunction · 0.85
replyUpdateUserFunction · 0.85

Calls 8

pluginActionToCrudFunction · 0.85
pbDefaultAcsSerializeFunction · 0.85
interfaceToBytesFunction · 0.85
UserIdMethod · 0.80
UidMethod · 0.80
PrintlnMethod · 0.80
AccountMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…