🐛 Fix check realm member issue

This commit is contained in:
LittleSheep 2024-06-23 01:07:03 +08:00
parent b58466e8f6
commit 608c52ace6

View File

@ -13,21 +13,6 @@ import (
"reflect" "reflect"
) )
func GetRealm(id uint) (models.Realm, error) {
var realm models.Realm
pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport")
if err != nil {
return realm, err
}
response, err := proto.NewRealmsClient(pc).GetRealm(context.Background(), &proto.RealmLookupRequest{
Id: lo.ToPtr(uint64(id)),
})
if err != nil {
return realm, err
}
return LinkRealm(response)
}
func GetRealmWithAlias(alias string) (models.Realm, error) { func GetRealmWithAlias(alias string) (models.Realm, error) {
var realm models.Realm var realm models.Realm
pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport")
@ -44,12 +29,16 @@ func GetRealmWithAlias(alias string) (models.Realm, error) {
} }
func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberResponse, error) { func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberResponse, error) {
var realm models.Realm
if err := database.C.Where("id = ?", realmId).First(&realm).Error; err != nil {
return nil, err
}
pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport")
if err != nil { if err != nil {
return nil, err return nil, err
} }
response, err := proto.NewRealmsClient(pc).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ response, err := proto.NewRealmsClient(pc).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{
RealmId: uint64(realmId), RealmId: uint64(realm.ExternalID),
UserId: lo.ToPtr(uint64(userId)), UserId: lo.ToPtr(uint64(userId)),
}) })
if err != nil { if err != nil {