From f6b3380ec827bed193ad4cd5237345a1d419dc54 Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Fri, 12 Jan 2024 10:10:14 -0300 Subject: [PATCH] sort msgs history on wenichats ticket open --- services/tickets/wenichats/service.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/tickets/wenichats/service.go b/services/tickets/wenichats/service.go index 253506015..f9f84de25 100644 --- a/services/tickets/wenichats/service.go +++ b/services/tickets/wenichats/service.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "sort" "strconv" "strings" "sync" @@ -168,6 +169,10 @@ func (s *service) Open(session flows.Session, topic *flows.Topic, body string, a msgs = append(msgs, frmsgs...) } + sort.Slice(msgs, func(i, j int) bool { + return msgs[i].CreatedOn().Before(msgs[j].CreatedOn()) + }) + //send history for _, msg := range msgs { var direction string