Commit Graph

15 Commits

Author SHA1 Message Date
Simon Ser
ea98ac042e Add Prometheus instrumentation for the database 2021-11-17 15:58:19 +01:00
Simon Ser
a6aa7f0008 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
2021-11-02 23:33:17 +01:00
Simon Ser
ce3d6df6b8 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.
2021-11-02 22:58:50 +01:00
Simon Ser
9ec1f1a5b0 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.
2021-10-18 19:15:15 +02:00
Hubert Hirtz
350057e60b Set hard timeouts on DB transactions 2021-10-15 22:39:14 +02:00
Hubert Hirtz
6e06663615 PostgreSQL support 2021-10-11 15:21:04 +02:00
Simon Ser
e177977c30 Add DB stats 2021-10-05 19:31:06 +02:00
Simon Ser
1b8d8d08c9 db_sqlite: fix realname not fetched in ListUsers
This fixes per-user realname not being used on bouncer startup.
2021-10-05 11:10:48 +02:00
Simon Ser
fce86b0f0d db_sqlite: switch to sql.Named
This allows us to avoid mixing up arguments.
2021-09-27 16:54:06 +02:00
Hubert Hirtz
6b9c99821a Fix DeliveryReceipt not being cleaned up 2021-09-21 18:19:05 +02:00
Hubert Hirtz
bc83d3a3ba 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.
2021-09-14 18:38:58 +02:00
Hubert Hirtz
4dce5a91c9 Explicitly close connection to SQLite on failed upgrade 2021-09-13 17:14:04 +02:00
Simon Ser
a14f646135 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.
2021-06-25 20:33:13 +02:00
Simon Ser
7d648f702e Allow networks to be disabled 2021-05-26 10:51:02 +02:00
Drew DeVault
61b68d6dfb db: refactor into interface
This refactors the SQLite-specific bits into db_sqlite.go. A future
patch will add PostgreSQL support.
2021-05-25 16:35:39 +02:00