From 364fda8a55adda07a3f8eaf786a064db56e423c0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 8 Dec 2024 12:45:28 +0800 Subject: [PATCH] :bug: Fix unable to create dm --- pkg/internal/http/api/direct_channels_api.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/internal/http/api/direct_channels_api.go b/pkg/internal/http/api/direct_channels_api.go index 3a0628d..27cb810 100644 --- a/pkg/internal/http/api/direct_channels_api.go +++ b/pkg/internal/http/api/direct_channels_api.go @@ -9,7 +9,6 @@ import ( "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/services" "github.com/gofiber/fiber/v2" @@ -26,7 +25,6 @@ func createDirectChannel(c *fiber.Ctx) error { Name string `json:"name" validate:"required"` Description string `json:"description"` RelatedUser uint `json:"related_user"` - IsEncrypted bool `json:"is_encrypted"` } if err := exts.BindAndValidate(c, &data); err != nil { @@ -46,10 +44,8 @@ func createDirectChannel(c *fiber.Ctx) error { } } - var relatedUser authm.Account - if err := database.C. - Where("external_id = ?", data.RelatedUser). - First(&relatedUser).Error; err != nil { + relatedUser, err := authkit.GetUser(gap.Nx, data.RelatedUser) + if err != nil { 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, err := services.NewChannel(channel) + channel, err = services.NewChannel(channel) if err != nil { return fiber.NewError(fiber.StatusBadRequest, err.Error()) }