fix sse
This commit is contained in:
parent
4f4f8f2938
commit
12c133352c
@ -2,6 +2,7 @@ package tickets
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gitea.pena/PenaSide/heruvym/internal/model"
|
||||
@ -13,7 +14,6 @@ import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/zap"
|
||||
"gopkg.in/telebot.v3"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Deps struct {
|
||||
@ -460,7 +460,8 @@ func (t *TicketController) allTickets(ctx context.Context, output chan interface
|
||||
//}
|
||||
|
||||
if err := t.dal.WatchAllTickets(ctx, func(ticket model.Ticket) error {
|
||||
output <- ticket
|
||||
msg, _ := json.Marshal(ticket)
|
||||
output <- msg
|
||||
return nil
|
||||
}); err != nil {
|
||||
output <- errors.New("cannot watch all tickets" + err.Error())
|
||||
@ -491,14 +492,16 @@ func (t *TicketController) userTickets(ctx context.Context, userID string, outpu
|
||||
}
|
||||
data = filteredData
|
||||
|
||||
output <- GetTicketsResp{data, count}
|
||||
msg, _ := json.Marshal(GetTicketsResp{data, count})
|
||||
output <- msg
|
||||
}
|
||||
|
||||
if err := t.dal.WatchTickets(ctx, userID, func(ticket model.Ticket) error {
|
||||
if ticket.TopMessage.System {
|
||||
return nil
|
||||
}
|
||||
output <- ticket
|
||||
msg, _ := json.Marshal(ticket)
|
||||
output <- msg
|
||||
return nil
|
||||
}); err != nil {
|
||||
output <- errors.New("cannot watch tickets")
|
||||
@ -517,7 +520,8 @@ func (t *TicketController) unauthorizedTickets(ctx context.Context, sess string,
|
||||
}
|
||||
|
||||
if tickets != nil {
|
||||
output <- GetTicketsResp{tickets, count}
|
||||
msg, _ := json.Marshal(GetTicketsResp{tickets, count})
|
||||
output <- msg
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user