From e443448a949a8e37cd677c42d62468c42ae873ec Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 5 May 2024 16:36:56 +0800 Subject: [PATCH] :bug: Fix link external realm --- pkg/services/realms.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/services/realms.go b/pkg/services/realms.go index 1a39999..bca84cb 100644 --- a/pkg/services/realms.go +++ b/pkg/services/realms.go @@ -10,6 +10,7 @@ import ( "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" "github.com/samber/lo" "gorm.io/gorm" + "reflect" ) func GetRealm(id uint) (models.Realm, error) { @@ -78,5 +79,18 @@ func LinkRealm(info *proto.RealmResponse) (models.Realm, error) { } return realm, err } - return realm, nil + + prev := realm + realm.Alias = info.Alias + realm.Name = info.Name + realm.Description = info.Description + realm.IsPublic = info.IsPublic + realm.IsCommunity = info.IsCommunity + + var err error + if !reflect.DeepEqual(prev, realm) { + err = database.C.Save(&realm).Error + } + + return realm, err }