fix: #1054 Add model mapping to abilities

- Update Abilities model to include model mapping key
- Parse model mapping in Channel model and filter models by model mapping in Update function
This commit is contained in:
Laisky.Cai
2024-02-29 08:58:54 +00:00
parent b747cdbc6f
commit 90a039d325
4 changed files with 36 additions and 4 deletions

View File

@@ -55,6 +55,21 @@ func (channel *Channel) AddAbilities() error {
abilities = append(abilities, ability)
}
}
// add keys of model mapping to abilities
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
}