From e43b9c93413aff2377b5354765ccdc6e41ab3e87 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 10 Mar 2025 22:01:16 +0800 Subject: [PATCH] :sparkles: Broadcast realm was deleted --- pkg/internal/services/realms.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/realms.go b/pkg/internal/services/realms.go index c300c4c..29fe3ed 100644 --- a/pkg/internal/services/realms.go +++ b/pkg/internal/services/realms.go @@ -1,12 +1,16 @@ package services import ( + "context" "errors" "fmt" "strconv" + "git.solsynth.dev/hypernet/nexus/pkg/nex" + "git.solsynth.dev/hypernet/nexus/pkg/proto" "git.solsynth.dev/hypernet/passport/pkg/authkit/models" "git.solsynth.dev/hypernet/passport/pkg/internal/database" + "git.solsynth.dev/hypernet/passport/pkg/internal/gap" "github.com/samber/lo" "gorm.io/gorm" ) @@ -187,5 +191,17 @@ func DeleteRealm(realm models.Realm) error { tx.Rollback() return err } - return tx.Commit().Error + if err := tx.Commit().Error; err != nil { + return err + } else { + conn := gap.Nx.GetNexusGrpcConn() + _, _ = proto.NewDirectoryServiceClient(conn).BroadcastEvent(context.Background(), &proto.EventInfo{ + Event: "deletion", + Data: nex.EncodeMap(map[string]any{ + "type": "realm", + "id": realm.ID, + }), + }) + } + return nil }