Commit Graph

9 Commits

Author SHA1 Message Date
Simon Ser
8a2a9706f7 go fmt 2023-10-24 16:54:19 +02:00
Calvin Lee
072e15d1e8 fix empty CHATHISTORY TARGETS
Currently, if times sent to `CHATHISTORY TARGETS` are reversed (e.g.
current time occurs first, and initial time occurs second) then no
targets will be returned from the database backend.

Changes have been tested with the sqlite backend.
2023-10-12 09:48:54 +02:00
Simon Ser
40a40566f4 msgstore/znclog: fix error message
err may be nil.

Fixes: 2b2a2fd479 ("msgstore/znclog: fix panic on malformed input line")
2023-05-23 23:11:05 +02:00
Simon Ser
2b2a2fd479 msgstore/znclog: fix panic on malformed input line
If the line is "[01:02:03]" without a trailing space, we trip on
a "slice bounds out of range" panic.

Closes: https://todo.sr.ht/~emersion/soju/214
2023-05-23 23:08:44 +02:00
Simon Ser
b6c0841291 msgstore: move ZNC log functions to separate package 2023-02-17 14:35:25 +01:00
delthas
1ccc7ce6d2 Add a database store for messages
This adds a new config option, `logs db`, which enables storing chat
logs in the soju database.

Regular store options, CHATHISTORY options, and SEARCH operations are
supported, like the fs logs backend.

Messages are stored in a new table, Message. In order to track the list
of targets we have messages for in an optimized manner, another database
is used: MessageTarget.

All new requests are backend by indexes so should be fast even with
hundreds of thousands of messages.

A contrib script is provided for migrating existing logs fs chat logs to
the database. It can be run with eg:

  go run ./contrib/migrate-logs/ logs/ sqlite3:soju.db

Co-authored-by: Simon Ser <contact@emersion.fr>
2023-02-17 14:13:43 +01:00
delthas
897c21dbb4 Truncate message times to the second when using the FS message store
The FS message store truncates message times to the second.

This means that a message sent out as 2020-01-01T00:00:00.123Z could be
sent later as part of a CHATHISTORY batch as 2020-01-01T00:00:00.000Z,
which could cause issues in clients.

One such issue is a client sending a MARKREAD for
2020-01-01T00:00:00.000Z, with another client considering the
2020-01-01T00:00:00.123Z message it has as unread.

This fixes the issue by truncating all message times to the second when
using the FS message store.
2022-11-28 17:54:13 +01:00
Simon Ser
106d40dcd4 Upgrade to gopkg.in/irc.v4 2022-11-14 12:06:58 +01:00
Simon Ser
620a8789b0 Add msgstore package 2022-05-09 16:25:57 +02:00