feat(account-users): align inviter id
This commit is contained in:
@@ -21,11 +21,11 @@ import (
|
||||
// after_save (update_presence_in_redis on availability change),
|
||||
// validates user_id uniqueness scoped to account_id
|
||||
type AccountUserService struct {
|
||||
repo *repository.AccountUserRepo
|
||||
notificationRepo *repository.NotificationSettingRepo
|
||||
accountRepo *repository.AccountRepo
|
||||
userRepo *repository.UserRepo
|
||||
eventBus *pubsub.EventBus
|
||||
repo *repository.AccountUserRepo
|
||||
notificationRepo *repository.NotificationSettingRepo
|
||||
accountRepo *repository.AccountRepo
|
||||
userRepo *repository.UserRepo
|
||||
eventBus *pubsub.EventBus
|
||||
}
|
||||
|
||||
// NewAccountUserService creates a new AccountUser service.
|
||||
@@ -78,10 +78,10 @@ func (s *AccountUserService) AddUserToAccount(ctx context.Context, accountID uin
|
||||
}
|
||||
|
||||
au := &model.AccountUser{
|
||||
AccountID: accountID,
|
||||
UserID: req.UserID,
|
||||
Role: req.Role,
|
||||
InvitedBy: req.InviterID,
|
||||
AccountID: accountID,
|
||||
UserID: req.UserID,
|
||||
Role: req.Role,
|
||||
InvitedBy: req.InviterID,
|
||||
Availability: "offline", // 1:1 Chatwoot: default availability
|
||||
AutoOffline: true, // 1:1 Chatwoot: default auto_offline
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (s *AccountUserService) AddUserToAccount(ctx context.Context, accountID uin
|
||||
"account_id": accountID,
|
||||
"user_id": req.UserID,
|
||||
"role": req.Role,
|
||||
"invited_by": req.InviterID,
|
||||
"inviter_id": req.InviterID,
|
||||
})
|
||||
if err := s.eventBus.Publish(pubsub.TopicAccountUserCreated, payload); err != nil {
|
||||
applogger.L().Errorf("Failed to publish AccountUserCreated event: %v", err)
|
||||
@@ -211,8 +211,8 @@ func (s *AccountUserService) createDefaultNotificationSetting(ctx context.Contex
|
||||
// 1:1 Chatwoot: email_conversation_assignment = bit 1 → 2
|
||||
// push_conversation_assignment = bit 1 → 2
|
||||
setting := &model.NotificationSetting{
|
||||
UserID: userID,
|
||||
AccountID: accountID,
|
||||
UserID: userID,
|
||||
AccountID: accountID,
|
||||
EmailFlags: 2, // bit 1 = email_conversation_assignment
|
||||
PushFlags: 2, // bit 1 = push_conversation_assignment
|
||||
}
|
||||
@@ -234,4 +234,4 @@ func (s *AccountUserService) SetAutoOffline(ctx context.Context, accountID, user
|
||||
// FindOnlineAgents returns all online agents for an account.
|
||||
func (s *AccountUserService) FindOnlineAgents(ctx context.Context, accountID uint) ([]model.AccountUser, error) {
|
||||
return s.repo.FindOnlineAgentsByAccount(ctx, accountID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user