Commit graph

406 commits

Author SHA1 Message Date
Simon Ser b1b4541a53 downstream: simplify NICK handling when disconnected 2022-07-08 18:14:10 +02:00
Simon Ser dc0a847240 Add per-user default nickname
The soju username is immutable. Add a separate nickname setting so
that users can change their nickname for all networks.

References: https://todo.sr.ht/~emersion/soju/110
2022-07-08 18:01:05 +02:00
Simon Ser 14cbd63412 Send MARKREAD push notifications
Allows clients to dismiss notifications when another client marks
the conversation as read.
2022-07-08 16:55:29 +02:00
Simon Ser 7e21e79eab downstream: fix MARKREAD/READ command name in broadcast
We wouldn't send a MARKREAD message to draft/read-marker downstreams
when receiving a READ command.
2022-07-08 15:17:30 +02:00
Simon Ser 0d44413e85 upstream: drop upstreamConn.nickCM
Removes an unnecessary source of truth.
2022-07-08 14:52:10 +02:00
Simon Ser e2e3e2731b Fix draft/read-marker entry in permanentDownstreamCaps
Oops.

Fixes: 71d639699e ("Add support for draft/read-marker")
2022-07-01 15:58:11 +02:00
Simon Ser 71d639699e Add support for draft/read-marker
References: https://github.com/ircv3/ircv3-specifications/pull/489
2022-07-01 13:33:28 +02:00
Simon Ser f0db261fc0 database: add missing user column to WebPushSubscription table
Some WebPushSubscription entries aren't tried to a network, in
which case the "network" column is NULL. But then all users share
the same row. Oops.

Fortunately network-less subscriptions aren't used for anything
yet, they're just stored. So the impact should be minimal.
2022-06-16 19:33:39 +02:00
Simon Ser de0992d41e downstream: fix panic in findWebPushSubscription for unbound conns
This code has been missed when adding webpush support for downstream
connections without an upstream network bound.
2022-06-15 09:09:28 +02:00
Simon Ser 3863b8cb6b Add webpush extension
References: https://github.com/ircv3/ircv3-specifications/pull/471
Co-authored-by: delthas <delthas@dille.cc>
2022-06-14 16:16:12 +02:00
Simon Ser fe40c51ff0 database: add User.{Check,Set}Password 2022-06-08 13:27:33 +02:00
Simon Ser 09f2cf8489 Don't provide name in channel casemapMap Set and ForEach
The name is already provided in the struct.
2022-06-06 10:05:31 +02:00
Simon Ser 657e25b25c Make casemapMap more type-safe
In addition to a type-safe getter, also define type-safe setters
and iterators.

References: https://lists.sr.ht/~emersion/soju-dev/patches/32777
2022-06-06 09:58:39 +02:00
Simon Ser c8f9728ff6 Drop size arg from newCasemapMap
It's unused.
2022-06-06 09:23:17 +02:00
Simon Ser 22b235602b Add soju.im/account-required
References: https://github.com/ircv3/ircv3-specifications/pull/492
2022-06-04 10:52:28 +02:00
Simon Ser 3c5e603192 Remove bridge.go
All of its functions belong to downstream.go.
2022-05-30 09:51:36 +02:00
Simon Ser da8f626e51 xirc: add GenerateSASL 2022-05-30 09:41:47 +02:00
Simon Ser f3b06f4236 xirc: move over WHOX helpers 2022-05-29 18:33:29 +02:00
Simon Ser 9b37bd2eaa xirc: move over CapRegistry 2022-05-29 18:33:22 +02:00
Simon Ser fa6f52ed08 xirc: encode tokens in GenerateIsupport 2022-05-29 18:24:10 +02:00
Simon Ser c10d382a7d xirfc: move over message generation functions 2022-05-29 17:57:21 +02:00
Simon Ser c50fb4a26d xirc: move command constants over 2022-05-09 17:18:51 +02:00
Simon Ser 620a8789b0 Add msgstore package 2022-05-09 16:25:57 +02:00
Simon Ser b92afa7cca Introduce an xirc package 2022-05-09 16:15:00 +02:00
Simon Ser 89412187d4 msgstore: rename searchMessageOptions, export fields
Preparation for splitting msgstore into a separate package.
2022-05-09 15:44:41 +02:00
Simon Ser f508d36c38 msgstore: add loadMessageOptions
A struct containing common parameters for all messageStore.Load*
functions returning messages.
2022-05-09 15:36:39 +02:00
Simon Ser 3a7dee8128 Introduce a database package 2022-05-09 15:08:04 +02:00
Simon Ser d37f946e83 downstream: fix setting tls=0 in bouncer-networks
The old code resulted in URLs like "irc+insecure://0".
2022-05-03 10:43:02 +02:00
Simon Ser 2e5474d05a downstream: improve error message on unrecognized message 2022-04-27 19:05:01 +02:00
Simon Ser f3932ab500 Drop user.forEachDownstream
It's just a for loop.
2022-04-15 10:32:28 +02:00
delthas b790db1423 Keep batch tag for downstreams with batch cap
On upstreams without message-tags support, we do not advertise
message-tags anymore. Still, we want to send the batch tag when the
client explicitly requested it.

This fixes a critical issue where we drop the batch tag on chathistory
messages for upstreams that do not support message-tags.
2022-04-12 17:58:36 +02:00
delthas 683cfe0615 Add support for the SEARCH extension 2022-04-12 17:58:16 +02:00
delthas b67b9b3cd2 Enable message-tags only when all upstreams support it
Previously, we would always advertise mesasge-tags. This made
downstreams believe they could send TAGMSG to the upstream, even though
the upstream did not support it.
2022-04-12 12:41:50 +02:00
delthas abe5291b62 Add support for the upstream echo-message capability
This adds support for upstream echo-message. This capability is
enabled when the upstream supports labeled-response.

When it is enabled, we don't echo downstream messages in the downstream
handler, but rather wait for the upstream to echo it, to produce it to
downstreams.

When it is disabled, we keep the same behaviour as before: produce the
message to all downstreams as soon as it is received from the
downstream.

In other words, the main functional difference is that when the upstream
supports labeled-response, the client will now receive an echo for its
messages when the server acknowledges them, rather than when soju acks
them.

Additionally, uc.produce was refactored to take an ID rather than a
downstream.
2022-04-11 17:27:47 +02:00
delthas f7a468194d bouncer-networks: Add a read-only error attribute
This is useful for clients to display additional info abotu why a
network is disconnected.
2022-04-11 08:38:31 +02:00
delthas d8ca6d2222 Enable resetting a BOUNCER NETWORK port
When a client sends BOUNCER CHANGENETWORK with no value (or an empty
port value), this means it wants to reset the port value to its default
value.

Previously we considered an empty port as an actual valid, empty port
value, which would then be used to connect to the server (dial
'example.com:' (ie 'example.com:0'), which failed.
2022-04-10 18:12:12 +02:00
Simon Ser 793ac29571 downstream: use upstream user/host for echo message 2022-04-05 10:09:49 +02:00
Simon Ser 9513c28208 downstream: unify PRIVMSG/NOTICE and TAGMSG codepaths
They are nearly identical, the only difference is that TAGMSG has
no text parameter.

Inspired from a patch from delthas:
https://lists.sr.ht/~emersion/soju-dev/patches/30651
2022-04-05 10:09:29 +02:00
Simon Ser 846c99dedc Queue WHOIS commands
This avoids having more than one in flight at a time (avoids
hitting rate limits a bit) and routes back replies to the correct
downstream connection (even if labeled-response isn't supported).

Closes: https://todo.sr.ht/~emersion/soju/193
2022-04-04 09:58:26 +02:00
Simon Ser 303c663d02 Refuse to change nick on bouncer connection
Also simplify the code.

Closes: https://todo.sr.ht/~emersion/soju/192
2022-04-01 14:55:36 +02:00
Simon Ser 29b1e6f47b downstream: update user realname on SETNAME 2022-03-30 17:51:04 +02:00
Simon Ser d7b5f5d12c downstream: set realname for network-less connections
Send the user-wide realname config. We still need to handle SETNAME
properly.
2022-03-30 14:17:09 +02:00
Simon Ser 0ec3e63ace downstream: send RPL_ENDOFWHO on unmarshalEntity error
Also remove a couple of outdated comments.
2022-03-23 19:15:52 +01:00
Simon Ser 44efe37292 downstream: clarify "user not active" error message 2022-03-23 13:11:37 +01:00
Simon Ser 43371bf347 Add the soju.im/no-implicit-names extension
References: https://github.com/ircv3/ircv3-ideas/issues/87
2022-03-22 21:03:20 +01:00
Simon Ser 128aefcc50 downstream: strip back "*" prefix 2022-03-21 17:16:02 +01:00
Simon Ser 8e4c8f7e5a downstream: copy message when degrading extended-join
Otherwise we mutate the input argument and loops over downstream
connections to send messages will be messed up.
2022-03-21 17:13:55 +01:00
Simon Ser 883683c0b7 downstream: always populate downstreamConn.username
This ensures we don't send a prefix without a username in it.
2022-03-21 16:37:04 +01:00
Simon Ser 069625d30d downstream: rejigger hostname logic in newDOwnstreamConn
I find it easier to read this way.
2022-03-21 16:33:58 +01:00
Simon Ser e403b88a3d Add support for chghost 2022-03-21 16:30:58 +01:00