🐛 Fix unable to create dm
This commit is contained in:
parent
f50e376f6c
commit
364fda8a55
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"git.solsynth.dev/hypernet/messaging/pkg/internal/http/exts"
|
"git.solsynth.dev/hypernet/messaging/pkg/internal/http/exts"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/messaging/pkg/internal/database"
|
|
||||||
"git.solsynth.dev/hypernet/messaging/pkg/internal/models"
|
"git.solsynth.dev/hypernet/messaging/pkg/internal/models"
|
||||||
"git.solsynth.dev/hypernet/messaging/pkg/internal/services"
|
"git.solsynth.dev/hypernet/messaging/pkg/internal/services"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
@ -26,7 +25,6 @@ func createDirectChannel(c *fiber.Ctx) error {
|
|||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
RelatedUser uint `json:"related_user"`
|
RelatedUser uint `json:"related_user"`
|
||||||
IsEncrypted bool `json:"is_encrypted"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := exts.BindAndValidate(c, &data); err != nil {
|
if err := exts.BindAndValidate(c, &data); err != nil {
|
||||||
@ -46,10 +44,8 @@ func createDirectChannel(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var relatedUser authm.Account
|
relatedUser, err := authkit.GetUser(gap.Nx, data.RelatedUser)
|
||||||
if err := database.C.
|
if err != nil {
|
||||||
Where("external_id = ?", data.RelatedUser).
|
|
||||||
First(&relatedUser).Error; err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to find related user: %v", err))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to find related user: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +71,7 @@ func createDirectChannel(c *fiber.Ctx) error {
|
|||||||
channel.RealmID = &realm.ID
|
channel.RealmID = &realm.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
channel, err := services.NewChannel(channel)
|
channel, err = services.NewChannel(channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user