49 Commits

Author SHA1 Message Date
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
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
2caeb0f764 Fix upstream USER command when both username and nick are empty
git-svn-id: file:///srv/svn/repo/suika/trunk@674 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-07 17:33:59 +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
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
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
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
yyp
e92b4b5cdf db: match placeholders with columns
Soju inserts 9 columns but only with 8 placeholders. This causes
channels not being saved properly and also logging errors like this:

    downstream ...: failed to create or update channel ...: 8 values for 9 columns

git-svn-id: file:///srv/svn/repo/suika/trunk@509 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-27 07:22:44 +00:00
contact
d36068af4e Store last internal msg ID in DB when detaching
References: https://todo.sr.ht/~emersion/soju/98

git-svn-id: file:///srv/svn/repo/suika/trunk@497 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 16:15:30 +00:00
contact
83a6c849fd Save delivery receipts in DB
This avoids loosing history on restart for clients that don't
support chathistory.

Closes: https://todo.sr.ht/~emersion/soju/80

git-svn-id: file:///srv/svn/repo/suika/trunk@489 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-31 16:04:13 +00:00
contact
37c710b832 Add Network.{URL,GetUsername,GetRealname}
Just a bunch of helpers that can be re-used.

git-svn-id: file:///srv/svn/repo/suika/trunk@457 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-09 17:55:34 +00:00
delthas
4ca0db44d3 Introduce Channel.{RelayDetached,ReattachOn,DetachAfter,DetachOn}
This adds several fields to the channel database schema and struct.
These fields will be used to add support for customizable message
relaying through BouncerServ, auto-reattaching, auto-detaching.

- RelayDetached is a filter for which notices to relay through
  BouncerServ for detached channels.
- ReattachOn is a filter for which messages to trigger a channel
  reattach on.
- DetachAfter is the duration after which to automatically detach a
  channel if no matching messages are received.
- DetachOn is a filter for which messages will reset the auto-detach
  timer.

git-svn-id: file:///srv/svn/repo/suika/trunk@434 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-14 19:54:02 +00:00
contact
5da0737bb4 Switch to sql.NullString
Not really better than what we had before, however new contributors will
maybe be familiar with it.

git-svn-id: file:///srv/svn/repo/suika/trunk@422 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 13:47:53 +00:00
contact
28c243adec Switch DB API to user IDs
This commit changes the Network schema to use user IDs instead of
usernames. While at it, a new UNIQUE(user, name) constraint ensures
there is no conflict with custom network names.

Closes: https://todo.sr.ht/~emersion/soju/86
References: https://todo.sr.ht/~emersion/soju/29

git-svn-id: file:///srv/svn/repo/suika/trunk@421 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 13:14:23 +00:00
contact
9f4e3bad1b Add id column to User table
We used rowid before, but an explicit ID column is cleaner.

git-svn-id: file:///srv/svn/repo/suika/trunk@420 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 12:52:55 +00:00
hubert
8ca570988a Make DB.DeleteChannel take the channel ID
... to allow the caller to correctly do any necessary casemapping.

git-svn-id: file:///srv/svn/repo/suika/trunk@416 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-07 09:40:18 +00:00
dan.shick
10e3974799 Fix store user query values
git-svn-id: file:///srv/svn/repo/suika/trunk@393 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-17 22:26:59 +00:00
contact
aa04c4bf88 Add User.ID
For now it's just a new field that'll be useful to generate user ident
strings. It uses the SQLite implicit rowid column. In the future the DB
interface will need to be updated to use user IDs instead of usernames.

git-svn-id: file:///srv/svn/repo/suika/trunk@382 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:26:42 +00:00
contact
676ffcc0b3 Add DB.DeleteUser
git-svn-id: file:///srv/svn/repo/suika/trunk@375 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-03 16:43:39 +00:00
contact
1bceed3bdb Fix deadlock in DB.Close
This method was calling itself, instead of the underlying SQLite
database's Close method.

git-svn-id: file:///srv/svn/repo/suika/trunk@356 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-09 09:23:51 +00:00
delthas
d6d3e9ed7a Add an admin flag to users
This is preparatory work for letting some users access admin-exclusive
service commands, such as creating new users.

This adds a boolean admin flag to the User schema. Old users will stay
non-admin after the DB migration.

git-svn-id: file:///srv/svn/repo/suika/trunk@327 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
contact
7c4131cbdb Introduce User.Created
For Network and Channel, the database only needed to define one Store
operation to create/update a record. However since User is missing an ID
we couldn't have a single StoreUser function like other types. We had
CreateUser and UpdatePassword. As new User fields get added (e.g. the
upcoming Admin flag) this isn't sustainable.

We could have CreateUser and UpdateUser, but this wouldn't be consistent
with other types. Instead, introduce User.Created which indicates
whether the record is already stored in the DB. This can be used in a
new StoreUser function to decide whether we need to UPDATE or INSERT
without relying on SQL constraints and INSERT OR UPDATE.

The ListUsers and GetUser functions set User.Created to true.

git-svn-id: file:///srv/svn/repo/suika/trunk@324 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 09:59:03 +00:00
fox.cpp
5f49770e07 Implement upstream SASL EXTERNAL support
Closes: https://todo.sr.ht/~emersion/soju/47

git-svn-id: file:///srv/svn/repo/suika/trunk@307 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-02 09:24:22 +00:00
contact
9f84047153 Add support for detached channels
Channels can now be detached by leaving them with the reason "detach",
and re-attached by joining them again. Upon detaching the channel is
no longer forwarded to downstream connections. Upon re-attaching the
history buffer is sent.

git-svn-id: file:///srv/svn/repo/suika/trunk@284 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 13:18:14 +00:00
contact
a448e04600 Add network.channels, remove DB.GetChannel
Store the list of configured channels in the network data structure.
This removes the need for a database lookup and will be useful for
detached channels.

git-svn-id: file:///srv/svn/repo/suika/trunk@267 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-23 14:36:20 +00:00
delthas
218af4327e Add support for custom network on-connect commands
Some servers use custom IRC bots with custom commands for registering to
specific services after connection.

This adds support for setting custom raw IRC messages, that will be
sent after registering to a network.

It also adds support for a custom flag.Value type for string
slice flags (flags taking several string values).

git-svn-id: file:///srv/svn/repo/suika/trunk@263 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:38:47 +00:00
contact
c82c640bd9 Set up DB migration infrastructure
The database is now initialized automatically on first run. The schema
version is stored in SQLite's user_version special field. Migrations are
stored in an array and applied based on the schema version.

git-svn-id: file:///srv/svn/repo/suika/trunk@255 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 20:45:02 +00:00
admin
88284aa7de Add ability to change password
git-svn-id: file:///srv/svn/repo/suika/trunk@251 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 08:09:02 +00:00
contact
9fe572eb4f Fix SQL error logged on JOIN
Closes: https://todo.sr.ht/~emersion/soju/40

git-svn-id: file:///srv/svn/repo/suika/trunk@207 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 15:34:22 +00:00
contact
d317a87876 Add "network delete" service command
And add all the infrastructure required to stop and delete networks.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@202 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 13:40:20 +00:00
contact
a17e0acde2 Stop accessing user data in downstreamConn.authenticate
This becomes racy once user.Password is updated on-the-fly.

git-svn-id: file:///srv/svn/repo/suika/trunk@173 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 21:38:38 +00:00
contact
9ffd959ce7 Correctly set Channel.ID in DB.StoreChannel
git-svn-id: file:///srv/svn/repo/suika/trunk@149 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 13:23:41 +00:00
contact
d4e5d3dfb4 Error out when storing unsupported SASL mechanism in DB
git-svn-id: file:///srv/svn/repo/suika/trunk@148 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 13:15:25 +00:00
contact
dd844bdefc Add support for channel keys
git-svn-id: file:///srv/svn/repo/suika/trunk@146 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 10:54:08 +00:00
delthas
0b5e3e828a schema: add Network.name
git-svn-id: file:///srv/svn/repo/suika/trunk@118 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-18 23:06:48 +00:00
contact
1a9d6a58a0 Rename project to soju
git-svn-id: file:///srv/svn/repo/suika/trunk@98 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-13 17:13:03 +00:00
contact
68b7b4461c Add support for SASL authentication
We now store SASL credentials in the database and automatically populate
them on NickServ REGISTER/IDENTIFY.

References: https://todo.sr.ht/~emersion/jounce/10

git-svn-id: file:///srv/svn/repo/suika/trunk@95 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-13 14:12:44 +00:00
contact
fb60233780 Add support for upstream PASS command
git-svn-id: file:///srv/svn/repo/suika/trunk@93 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-13 11:06:02 +00:00
contact
9eb7349674 Store NICK changes in the DB
git-svn-id: file:///srv/svn/repo/suika/trunk@90 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-12 18:17:06 +00:00
contact
9eee83f69d Update DB on JOIN and PART
git-svn-id: file:///srv/svn/repo/suika/trunk@89 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-12 17:33:03 +00:00
contact
ebad23e080 Add support for PASS to downstream
git-svn-id: file:///srv/svn/repo/suika/trunk@85 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-11 18:09:32 +00:00
contact
79f3b73eab cmd/jouncectl: new command
Allows to create users.

git-svn-id: file:///srv/svn/repo/suika/trunk@84 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-11 18:01:03 +00:00
contact
b6d2338737 Use a RWMutex for DB
git-svn-id: file:///srv/svn/repo/suika/trunk@81 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 19:15:38 +00:00
contact
c75d825938 go fmt
git-svn-id: file:///srv/svn/repo/suika/trunk@79 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 18:23:24 +00:00
contact
18c962e5c0 Add SQLite database
Closes: https://todo.sr.ht/~emersion/jounce/9

git-svn-id: file:///srv/svn/repo/suika/trunk@77 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 17:22:58 +00:00