feat: Map channel model changes to ability mappings

Fix: Add model mappings to a channel's abilities

- Add model mappings to a channel's abilities.
- Add model mapping unit tests.
This commit is contained in:
Laisky.Cai 2024-02-29 06:55:55 +00:00
parent 3da0f62055
commit 6ee7281a0a

View File

@ -55,6 +55,21 @@ func (channel *Channel) AddAbilities() error {
abilities = append(abilities, ability)
}
}
// add model mappings
for model := range channel.GetModelMapping() {
for _, group := range groups_ {
ability := Ability{
Group: group,
Model: model,
ChannelId: channel.Id,
Enabled: channel.Status == common.ChannelStatusEnabled,
Priority: channel.Priority,
}
abilities = append(abilities, ability)
}
}
return DB.Create(&abilities).Error
}