From 6ee7281a0ad88e2b3646cc8de7a2a6cc0e69ecde Mon Sep 17 00:00:00 2001 From: "Laisky.Cai" Date: Thu, 29 Feb 2024 06:55:55 +0000 Subject: [PATCH] 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. --- model/ability.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/model/ability.go b/model/ability.go index 7127abc3..e95c06f6 100644 --- a/model/ability.go +++ b/model/ability.go @@ -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 }