From af6ccd597024aa867a5742a5c6771c9a11c18c9f Mon Sep 17 00:00:00 2001 From: bt Date: Tue, 26 May 2026 12:13:46 +0200 Subject: [daemon] Fix users history --- server/user.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'server/user.go') diff --git a/server/user.go b/server/user.go index 9a0a71b..69b7ced 100644 --- a/server/user.go +++ b/server/user.go @@ -161,7 +161,7 @@ func (s *Server) handleUsermode(user *User, conn net.Conn, mode core.Usermode) e // TODO: Better errors func (s *Server) handleHistory(user *User, conn net.Conn, hist core.History) error { - _, err := core.ReadAddr(hist.Channel) + addr, err := core.ReadAddr(hist.Channel) if err != nil { fmt.Println("cannot parse address:", err) return user.Send(conn, core.Error{core.ErrorNotFound}) @@ -178,7 +178,17 @@ func (s *Server) handleHistory(user *User, conn net.Conn, hist core.History) err return user.Send(conn, core.Error{core.ErrorNotFound}) } - messages, err := s.Storage.GetHistory(hist.Channel, hist.Since, int(hist.Count), int(hist.Offset)) + var messages []core.Message + count := int(hist.Count) + offset := int(hist.Offset) + + if addr.Type == core.AddrUser { + messages, err = s.Storage.GetHistoryUser(user.Addr, hist.Channel, hist.Since, count, offset) + + } else { + messages, err = s.Storage.GetHistory(hist.Channel, hist.Since, count, offset) + } + if err != nil { fmt.Println("cannot get message history:", err) return user.Send(conn, core.Error{core.ErrorNotFound}) -- cgit v1.2.3