Skip to content

Commit

Permalink
debug send users
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Mar 16, 2023
1 parent 45659ee commit 49bb5e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alert/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ func (e *Dispatch) Send(rule *models.AlertRule, event *models.AlertCurEvent, not
logger.Warningf("no sender for channel: %s", channel)
continue
}
logger.Debugf("send event: %s, channel: %s, uids: %+v", event.Hash, channel, ctx.Users)
logger.Debugf("send event: %s, channel: %s", event.Hash, channel)
for i := 0; i < len(ctx.Users); i++ {
logger.Debug("send event to user: ", ctx.Users[i])
}
s.Send(ctx)
}

Expand Down
9 changes: 9 additions & 0 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ func (u *User) TableName() string {
return "users"
}

func (u *User) String() string {
bs, err := u.Contacts.MarshalJSON()
if err != nil {
return err.Error()
}

return fmt.Sprintf("<id:%d username:%s nickname:%s email:%s phone:%s contacts:%s>", u.Id, u.Username, u.Nickname, u.Email, u.Phone, string(bs))
}

func (u *User) IsAdmin() bool {
for i := 0; i < len(u.RolesLst); i++ {
if u.RolesLst[i] == AdminRole {
Expand Down

0 comments on commit 49bb5e1

Please sign in to comment.