🐛 Fix user cannot end own call
🐛 Fix get realm member issue
This commit is contained in:
parent
6e2d0b11d9
commit
f4a29faadf
@ -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))
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user