🐛 Fix power level check doesn't work in channel with realm

This commit is contained in:
LittleSheep 2024-07-11 19:00:49 +08:00
parent edd02a03f7
commit 5b2fa00b1e
2 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package api
import (
"fmt"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
@ -98,6 +99,8 @@ func newRawEvent(c *fiber.Ctx) error {
channel, member, err = services.GetAvailableChannelWithAlias(alias, user, val.ID)
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
} else if member.PowerLevel < 0 {
return fiber.NewError(fiber.StatusForbidden, "you have not enough permission to send message")
}
} else {
channel, member, err = services.GetAvailableChannelWithAlias(alias, user)

View File

@ -39,6 +39,8 @@ func newMessageEvent(c *fiber.Ctx) error {
channel, member, err = services.GetAvailableChannelWithAlias(alias, user, val.ID)
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
} else if member.PowerLevel < 0 {
return fiber.NewError(fiber.StatusForbidden, "you have not enough permission to send message")
}
} else {
channel, member, err = services.GetAvailableChannelWithAlias(alias, user)