Commit Graph

331 Commits

Author SHA1 Message Date
sad b75214f9ea
fuck it up 2024-04-07 14:58:24 -06:00
Simon Ser e184c30cef upstream: consoldate TCP dial into function 2023-12-21 13:57:28 +01:00
Antonio Mika c859d2134a Update user.go to not broadcast a push notification when generated from us 2023-11-17 15:30:54 +01:00
Simon Ser d354a30b43 upstream: use unspecified AWAY reason if possible 2023-11-12 16:37:46 +01:00
Calvin Lee bb8397057e Fix saving `+draft/react` is msgstores
This commit fixes a bug where only TAGMSGs with a `+react` tag would be
stored, when a `+draft/react` tag is normative. I have kept messages
containing `+react` as well, as they will most likely be used in the
future.

I have also reversed the order of tag inspection, as I found the new
order to be more readable.
2023-10-25 16:57:11 +02:00
Eric Mertens 60b041419a Only log unhandled messages in debug mode 2023-09-22 23:31:02 +09:00
Eric Mertens be3c6d72c1
Add support for STATUSMSG
This passes the STATUSMSG isupport through, and it ignores statusmsg prefix when routing messages through the PRIVMSG, NOTICE, and TAGMSG handler so they will show up in the correct history. Because it doesn't modify the message the statusmsg sigils show up correctly for the user on receipt.

Without this PR the statusmsg messages still come through to the client, but they get misrouted by clients expecting STATUSMSG to be specified in 005 and they don't go into the right channel history.

Closes: https://todo.sr.ht/~emersion/soju/124
2023-08-26 12:37:20 +02:00
Simon Ser 01b28fa85d Use * instead of nick in some numeric replies
This argument is supposed to be the destination client, but is
useless. Simplify our functions by sending * instead.
2023-08-23 19:50:37 +02:00
Eric Mertens 3650446156 Pass MODE and TOPIC through for unjoined channels 2023-08-23 19:44:55 +02:00
Eric Mertens 15e31e629a ERR_NOSUCHSERVER unqueues WHOIS 2023-08-16 20:58:02 +02:00
Eric Mertens d9db48d879 Don't drop RPL_LISTSTART - passthrough to downstream 2023-08-13 20:28:55 +02:00
Simon Ser 6f01bd86c3 downstream: pass context to SendMessage
Just like upstream does.
2023-04-06 13:23:20 +02:00
Simon Ser 51768c256a upstream: introduce upstreamConn.forwardMessage 2023-04-06 13:10:18 +02:00
Simon Ser 5358d93ab9 upstream: don't print "unhandled message" for registration errors 2023-04-03 22:35:38 +02:00
Simon Ser b514306a06 upstream: forward ERR_NOSUCHNICK 2023-04-03 22:35:16 +02:00
Simon Ser b0f2f9c36b upstream: add forwardMsgByID 2023-04-03 22:32:49 +02:00
Simon Ser ebd101820b Migrate casemapMap to xirc 2023-03-01 13:52:33 +01:00
Simon Ser 2b7a83b676 Take case-mapping as param in newCasemapMap()
Avoids situations where we forget to initialize it.
2023-03-01 13:43:51 +01:00
Simon Ser 3eb2679612 Migrate case-mapping to xirc 2023-03-01 13:35:03 +01:00
Simon Ser 07cd1f2f5d Use generics for casemapMap 2023-03-01 13:15:38 +01:00
Simon Ser 9b31dbfb24 upstream: drop unnecessary network nil check
Remnant from multi-upstream.
2023-03-01 11:52:42 +01:00
Simon Ser 437f7a74f0 upstream: convert ISUPPORT tokens to upper-case 2023-02-28 18:41:10 +01:00
Simon Ser 2dfb31ac0b upstream: drop unnecessary casemapIsSet field 2023-02-28 18:40:07 +01:00
Simon Ser c79fc0c19e Add support for SASL OAUTHBEARER 2023-01-30 11:53:01 +01:00
rj1 be185fba33 Implement TLS fingerprint pinning
Closes: https://todo.sr.ht/~emersion/soju/56
2022-12-16 17:44:14 +01:00
delthas 2604a14b7f Store only select TAGMSG types in message stores
We only want to store TAGMSG that should be persistent. +typing TAGMSG
should be dropped, but +react messages should be kept.

This introduces a whitelist for TAGMSG labels. We only store TAGMSG
having a least one tag in that whitelist.
2022-12-16 13:08:44 +01:00
delthas 58ee475265 Avoid sending push notifications for all channel context messages
...Instead, send them only when their text content contains the user
nick, as if they were regular channel messages.
2022-12-01 18:18:04 +01:00
Simon Ser ec2c0685dd Add WHO cache
This adds a new field to upstreams, members, which is a casemapped map
of upstream users known to the soju. The upstream users known to soju
are: self, any monitored user, and any user with whom we share a
channel.

The information stored for each upstream user corresponds to the info
that can be returned by a WHO/WHOX command.

We build the upstream user information both incrementally, capturing
information contained in JOIN and AWAY messages; and with the bulk user
information contained in WHO replies we receive.

This lets us build a user cache that can then be used to return
synthetic WHO responses to later WHO requests by downstreams.

This is useful because some networks (eg Libera) heavily throttle WHO
commands, and without this cache, any downstream connecting would send 1
WHO command per channel, so possibly more than a dozen WHO commands,
which soju then forwarded to the upstream as WHO commands.

With this cache most WHO commands can be cached and avoid sending
WHO commands to the upstream.

In order to cache the "flags" field, we synthetize the field from user
info we get from incremental messages: away status (H/G) and bot status
(B). This could result in incorrect values for proprietary user fields.
Support for the server-operator status (*) is also not supported.

Of note is that it is difficult to obtain a user "connected server"
field incrementally, so clients that want to maximize their WHO cache
hit ratio can use WHOX to only request fields they need, and in
particular not include the server field flag.

Co-authored-by: delthas <delthas@dille.cc>
2022-12-01 15:50:33 +01:00
delthas ac578823dc Fix clearing webpush targets after any MARKREAD
Previously, we would clear webpush targets after any MARKREAD.

Consider the following scenario (ignore any typos, this is crafted by
hand):

    <<< @time=2020-01-01T00:00:00Z PRIVMSG #foo :hi mark!
    <<< @time=2020-01-02T00:00:00Z PRIVMSG #foo :hi again mark!
    >>> MARKREAD #foo timestamp=2020-01-01T00:00:00Z
    >>> MARKREAD #foo timestamp=2020-01-02T00:00:00Z

The push target was previously cleared on the first MARKREAD, which
means that the second MARKREAD was never broadcast to Firebase, and all
devices would keep the "hi again mark!" notification indefinitely.

This changes the webpush target map so that we store a timestamp of the
last highlight we sent. We only clear the push target when sending a
MARKREAD that is at or after the last message.
2022-11-28 17:55:19 +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 6ad3dcc396 Use ratified extended-monitor cap name
References: https://github.com/ircv3/ircv3-specifications/pull/508
2022-11-06 20:36:33 +01:00
zsrv 926dcb37ac Make the auto-away functionality configurable 2022-09-26 19:52:07 +02:00
Simon Ser f646dc9ff2 irc: drop needMarshaling from applyChannelModes return values
Not used anymore.
2022-09-26 16:57:05 +02:00
Simon Ser a02a06de0d upstream: use forEachDownstreamByID to forward RPL_AWAY
It's a reply to a command. If possible, avoid broadcasting it to
all connected clients.
2022-09-26 16:57:05 +02:00
Simon Ser b78d8be490 upstream: remove heuristic to marshal nick in errors 2022-09-26 16:57:05 +02:00
Simon Ser 8a2f544806 downstream: drop downstreamConn.marshalEntity
This is a no-op.
2022-09-26 16:57:05 +02:00
Simon Ser 31957a9ac4 downstream: drop downstreamConn.marshalMessage
It's a no-op.
2022-09-26 16:57:05 +02:00
Simon Ser 25257b8892 downstream: drop downstreamConn.marshalUserPrefix
This is now a no-op.
2022-09-26 16:57:05 +02:00
Ember Sawady aee65cd269 Fix labeled-response without downstream echo-message
Previously, receiving labeled responses to messages sent from a
downstream without echo-message would fail, because soju would filter
out the responses under the assumption that it was an echoed message.
Only do this filtering when msg.Prefix.Name != uc.nick in order to avoid
this issue.
2022-09-06 15:15:34 +02:00
Simon Ser 6ba63aec4f go fmt 2022-08-23 09:53:11 +02:00
Ember Sawady 57584c08ed Fix NICK on upstreams supporting MONITOR
Previously, uc.network.Network.Nick wasn't successfully updated on
downstream NICK. This would cause soju to immediately switch back to the
old nick when the upstream supported MONITOR, so long as the network had
a nick configured as of initialization.

In addition, stop monitoring our desired nick once we've successfully
switched to it once, in order to not immediately undo server-induced
nick changes.
2022-08-23 09:39:24 +02:00
Simon Ser 65f0b2367e Broadcast Web Push subscriptions in a new goroutine 2022-08-17 16:09:12 +02:00
Simon Ser 1ee5dc062d upstream: add timeout for pending commands
References: https://todo.sr.ht/~emersion/soju/194
2022-08-17 15:45:05 +02:00
Simon Ser af95bc3a4f upstream: regain desired nick when MONITOR is missing
We already have logic to regain our desired nick when the upstream
server supports MONITOR. However some networks (e.g. OFTC, Rizon)
don't support MONITOR. Also try to regain our desired nick in that
case, by periodically sending NICK commands.

Closes: https://todo.sr.ht/~emersion/soju/197
2022-07-14 12:25:47 +02:00
Simon Ser a24cc5c969 upstream: pre-registration NOTICEs come from servers
There's no way another user is aware that we exist before
RPL_WELCOME.
2022-07-13 09:02:03 +02:00
Simon Ser 4e683af535 Aggregate AWAY status from all connected clients
Closes: https://todo.sr.ht/~emersion/soju/200
2022-07-11 19:36:12 +02:00
Simon Ser 9ba03b9095 upstream: ignore RPL_ENDOFWHO without pending command 2022-07-11 11:25:19 +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 0d44413e85 upstream: drop upstreamConn.nickCM
Removes an unnecessary source of truth.
2022-07-08 14:52:10 +02:00