diff --git a/pkg/internal/server/api/channel_members_api.go b/pkg/internal/server/api/channel_members_api.go index 15b8f46..d4cc06b 100644 --- a/pkg/internal/server/api/channel_members_api.go +++ b/pkg/internal/server/api/channel_members_api.go @@ -213,7 +213,7 @@ func joinChannel(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusBadRequest, "you was impossible to join a channel without related realm") } - if realm, err := services.GetRealm(channel.Realm.ExternalID); err != nil { + if realm, err := services.GetRealmWithExtID(channel.Realm.ExternalID); err != nil { return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("invalid channel, related realm was not found: %v", err)) } else if _, err := services.GetRealmMember(realm.ExternalID, user.ExternalID); err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("you are not a part of the realm: %v", err)) diff --git a/pkg/internal/services/calls.go b/pkg/internal/services/calls.go index fcdbd52..b7513f3 100644 --- a/pkg/internal/services/calls.go +++ b/pkg/internal/services/calls.go @@ -69,7 +69,7 @@ func GetOngoingCall(channel models.Channel) (models.Call, error) { func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call, error) { call := models.Call{ ExternalID: channel.Alias, - FounderID: founder.ID, + FounderID: founder.AccountID, ChannelID: channel.ID, Founder: founder, Channel: channel, diff --git a/pkg/internal/services/realms.go b/pkg/internal/services/realms.go index bef5d35..cdc1f94 100644 --- a/pkg/internal/services/realms.go +++ b/pkg/internal/services/realms.go @@ -13,7 +13,7 @@ import ( "reflect" ) -func GetRealm(id uint) (models.Realm, error) { +func GetRealmWithExtID(id uint) (models.Realm, error) { var realm models.Realm pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") if err != nil { @@ -44,12 +44,16 @@ func GetRealmWithAlias(alias string) (models.Realm, 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") if err != nil { return nil, err } response, err := proto.NewRealmsClient(pc).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ - RealmId: uint64(realmId), + RealmId: uint64(realm.ExternalID), UserId: lo.ToPtr(uint64(userId)), }) if err != nil {