🐛 Fix provide the cloned realm id to remote

This commit is contained in:
LittleSheep 2024-05-05 21:18:53 +08:00
parent e443448a94
commit 9e25e7e6cc

View File

@ -79,7 +79,7 @@ func createChannel(c *fiber.Ctx) error {
var realm *models.Realm
if val, ok := c.Locals("realm").(models.Realm); ok {
if info, err := services.GetRealmMember(val.ID, user.ExternalID); err != nil {
if info, err := services.GetRealmMember(val.ExternalID, user.ExternalID); err != nil {
return fmt.Errorf("you must be a part of that realm then can create channel related to it")
} else if info.GetPowerLevel() < 50 {
return fmt.Errorf("you must be a moderator of that realm then can create channel related to it")
@ -120,7 +120,7 @@ func editChannel(c *fiber.Ctx) error {
tx := database.C.Where(&models.Channel{BaseModel: models.BaseModel{ID: uint(id)}})
if val, ok := c.Locals("realm").(models.Realm); ok {
if info, err := services.GetRealmMember(val.ID, user.ExternalID); err != nil {
if info, err := services.GetRealmMember(val.ExternalID, user.ExternalID); err != nil {
return fmt.Errorf("you must be a part of that realm then can edit channel related to it")
} else if info.GetPowerLevel() < 50 {
return fmt.Errorf("you must be a moderator of that realm then can edit channel related to it")
@ -151,7 +151,7 @@ func deleteChannel(c *fiber.Ctx) error {
tx := database.C.Where(&models.Channel{BaseModel: models.BaseModel{ID: uint(id)}})
if val, ok := c.Locals("realm").(models.Realm); ok {
if info, err := services.GetRealmMember(val.ID, user.ExternalID); err != nil {
if info, err := services.GetRealmMember(val.ExternalID, user.ExternalID); err != nil {
return fmt.Errorf("you must be a part of that realm then can delete channel related to it")
} else if info.GetPowerLevel() < 50 {
return fmt.Errorf("you must be a moderator of that realm then can delete channel related to it")