diff options
| author | bt <bt@rctt.net> | 2026-05-26 12:13:46 +0200 |
|---|---|---|
| committer | bt <bt@rctt.net> | 2026-05-26 12:13:46 +0200 |
| commit | af6ccd597024aa867a5742a5c6771c9a11c18c9f (patch) | |
| tree | d24acf3999d8a930dbca52bf995b4f75010731de /server | |
| parent | 5d689490cc90f0698802a01d2d058cfdc382a382 (diff) | |
| download | solec-af6ccd597024aa867a5742a5c6771c9a11c18c9f.tar.gz solec-af6ccd597024aa867a5742a5c6771c9a11c18c9f.zip | |
[daemon] Fix users historyv0.5.2
Diffstat (limited to 'server')
| -rw-r--r-- | server/storage.go | 3 | ||||
| -rw-r--r-- | server/user.go | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/server/storage.go b/server/storage.go index 1cb725f..99402c8 100644 --- a/server/storage.go +++ b/server/storage.go @@ -8,7 +8,8 @@ import ( type Storage interface { AddMessage(msg core.Message) (err error) - GetHistory(channel string, since time.Time, num, offset int) (history []core.Message, err error) + GetHistory(target string, since time.Time, num, offset int) (history []core.Message, err error) + GetHistoryUser(user1, user2 string, since time.Time, num, offset int) (history []core.Message, err error) SetUser(user core.UserData) error DelUser(name string) error 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}) |
