✨ Able to get the creator details of channel
This commit is contained in:
@ -10,10 +10,8 @@ import (
|
||||
func getChannel(c *fiber.Ctx) error {
|
||||
alias := c.Params("channel")
|
||||
|
||||
var channel models.Channel
|
||||
if err := database.C.Where(&models.Channel{
|
||||
Alias: alias,
|
||||
}).First(&channel).Error; err != nil {
|
||||
channel, err := services.GetChannelWithAlias(alias)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func unifiedGateway(c *websocket.Conn) {
|
||||
func messageGateway(c *websocket.Conn) {
|
||||
user := c.Locals("principal").(models.Account)
|
||||
|
||||
// Push connection
|
@ -1,13 +1,14 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hydrogen/messaging/pkg"
|
||||
"github.com/gofiber/contrib/websocket"
|
||||
"github.com/gofiber/fiber/v2/middleware/favicon"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hydrogen/messaging/pkg"
|
||||
"github.com/gofiber/contrib/websocket"
|
||||
"github.com/gofiber/fiber/v2/middleware/favicon"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cache"
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
@ -103,7 +104,7 @@ func NewServer() {
|
||||
channels.Post("/:channel/calls/ongoing/token", authMiddleware, exchangeCallToken)
|
||||
}
|
||||
|
||||
api.Get("/unified", authMiddleware, websocket.New(unifiedGateway))
|
||||
api.Get("/ws", authMiddleware, websocket.New(messageGateway))
|
||||
}
|
||||
|
||||
A.Use(favicon.New(favicon.Config{
|
||||
|
@ -2,6 +2,7 @@ package services
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.solsynth.dev/hydrogen/messaging/pkg/database"
|
||||
"git.solsynth.dev/hydrogen/messaging/pkg/models"
|
||||
"github.com/samber/lo"
|
||||
@ -11,7 +12,7 @@ func GetChannel(id uint) (models.Channel, error) {
|
||||
var channel models.Channel
|
||||
if err := database.C.Where(models.Channel{
|
||||
BaseModel: models.BaseModel{ID: id},
|
||||
}).First(&channel).Error; err != nil {
|
||||
}).Preload("Account").First(&channel).Error; err != nil {
|
||||
return channel, err
|
||||
}
|
||||
|
||||
@ -22,7 +23,7 @@ func GetChannelWithAlias(alias string) (models.Channel, error) {
|
||||
var channel models.Channel
|
||||
if err := database.C.Where(models.Channel{
|
||||
Alias: alias,
|
||||
}).First(&channel).Error; err != nil {
|
||||
}).Preload("Account").First(&channel).Error; err != nil {
|
||||
return channel, err
|
||||
}
|
||||
|
||||
@ -67,7 +68,7 @@ func GetAvailableChannel(id uint, user models.Account) (models.Channel, models.C
|
||||
|
||||
func ListChannel() ([]models.Channel, error) {
|
||||
var channels []models.Channel
|
||||
if err := database.C.Find(&channels).Error; err != nil {
|
||||
if err := database.C.Preload("Account").Find(&channels).Error; err != nil {
|
||||
return channels, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user