20 Commits

Author SHA1 Message Date
yakumo.izuru
4f6ddb99ae Same logic as c5fa22a71d but in reverse
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/suika/trunk@819 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2023-05-19 19:45:14 +00:00
koizumi.aoi
94fa2da825 feat: replace mattn/go-sqlite3 with modernc.org/sqlite - this also means CGo is not needed anymore
git-svn-id: file:///srv/svn/repo/suika/trunk@813 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2023-03-23 19:27:39 +00:00
koizumi.aoi
cd99ccc1de Drunk as I like
Signed-off-by: Aoi K <koizumi.aoi@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/suika/trunk@804 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2023-03-21 04:45:19 +00:00
contact
3dbc059a7b Introduce formatServerTime
It's too easy to forget to convert to UTC.

git-svn-id: file:///srv/svn/repo/suika/trunk@784 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-16 13:45:09 +00:00
delthas
9b1a5bd469 Add support for the wip soju.im/read capability and READ command
READ lets downstream clients share information between each other about
what messages have been read by other downstreams.

Each target/entity has an optional corresponding read receipt, which is
stored as a timestamp.

- When a downstream sends:
  READ #chan timestamp=2020-01-01T01:23:45.000Z
  the read receipt for that target is set to that date
- soju sends READ to downstreams:
  - on JOIN, if the client uses the soju.im/read capability
  - when the read receipt timestamp is set by any downstream

The read receipt date is clamped by the previous receipt date and the
current time.

git-svn-id: file:///srv/svn/repo/suika/trunk@781 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-11 18:41:46 +00:00
contact
8b44d4ce3c Add Prometheus instrumentation for the database
git-svn-id: file:///srv/svn/repo/suika/trunk@712 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +00:00
contact
70a12fc286 Make Network.Nick optional
Make Network.Nick optional, default to the user's username. This
will allow adding a global setting to set the nickname in the
future, just like we have for the real name.

References: https://todo.sr.ht/~emersion/soju/110

git-svn-id: file:///srv/svn/repo/suika/trunk@664 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-02 22:33:17 +00:00
contact
2e071c0be7 db_sqlite: use TEXT instead of VARCHAR
VARCHAR(n) is pointless in SQLite and is the same as TEXT. Don't
bother with a migration since they're equivalent.

Also remove some unnecessary DEFAULT NULL statements.

git-svn-id: file:///srv/svn/repo/suika/trunk@663 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-02 21:58:50 +00:00
contact
2748715183 Add context args to Database interface
This is a mecanical change, which just lifts up the context.TODO()
calls from inside the DB implementations to the callers.

Future work involves properly wiring up the contexts when it makes
sense.

git-svn-id: file:///srv/svn/repo/suika/trunk@652 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-18 17:15:15 +00:00
hubert
753f1704e5 Set hard timeouts on DB transactions
git-svn-id: file:///srv/svn/repo/suika/trunk@645 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-15 20:39:14 +00:00
hubert
bbe15df672 PostgreSQL support
git-svn-id: file:///srv/svn/repo/suika/trunk@620 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-11 13:21:04 +00:00
contact
97110c193a Add DB stats
git-svn-id: file:///srv/svn/repo/suika/trunk@607 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-05 17:31:06 +00:00
contact
3131c1ef6e db_sqlite: fix realname not fetched in ListUsers
This fixes per-user realname not being used on bouncer startup.

git-svn-id: file:///srv/svn/repo/suika/trunk@598 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-05 09:10:48 +00:00
contact
1dfd2238c0 db_sqlite: switch to sql.Named
This allows us to avoid mixing up arguments.

git-svn-id: file:///srv/svn/repo/suika/trunk@596 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-09-27 14:54:06 +00:00
hubert
37a8fe455d Fix DeliveryReceipt not being cleaned up
git-svn-id: file:///srv/svn/repo/suika/trunk@595 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-09-21 16:19:05 +00:00
hubert
b19b03fa6d Use NULL-tolerant comparison for DeliveryReceipts
Since NULL = NULL is always FALSE, this query needs to use IS instead.
This should fix the flood of DeliveryReceipts in the DB.

See https://www.sqlite.org/lang_expr.html

> The IS and IS NOT operators work like = and != except when one or both
> of the operands are NULL. In this case, if both operands are NULL,
> then the IS operator evaluates to 1 (true) and the IS NOT operator
> evaluates to 0 (false). If one operand is NULL and the other is not,
> then the IS operator evaluates to 0 (false) and the IS NOT operator is
> 1 (true). It is not possible for an IS or IS NOT expression to
> evaluate to NULL.

git-svn-id: file:///srv/svn/repo/suika/trunk@589 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-09-14 16:38:58 +00:00
hubert
e0e9f5d21a Explicitly close connection to SQLite on failed upgrade
git-svn-id: file:///srv/svn/repo/suika/trunk@588 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-09-13 15:14:04 +00:00
contact
474d6e3ccd Add per-user realname setting
This allows users to set a default realname used if the per-network
realname isn't set.

A new "user update" command is introduced and can be extended to edit
other user properties and other users in the future.

git-svn-id: file:///srv/svn/repo/suika/trunk@568 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-25 18:33:13 +00:00
contact
30c6e9e954 Allow networks to be disabled
git-svn-id: file:///srv/svn/repo/suika/trunk@542 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-26 08:51:02 +00:00
sir
2f5c2a2edd db: refactor into interface
This refactors the SQLite-specific bits into db_sqlite.go. A future
patch will add PostgreSQL support.

git-svn-id: file:///srv/svn/repo/suika/trunk@531 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:35:39 +00:00