Commit Graph

40 Commits

Author SHA1 Message Date
Skip R
2310d2c036 usercache: rename methods
"Update" better expresses what is being done to the cache.
2026-02-06 17:55:46 -08:00
Skip R
d8ca44ecd9 connector: implement user cache
* Fixes the totally broken UserInfo resolution in guilds.
* Adds support for USER_UPDATE from the gateway.

Design considerations behind the user cache:

* Explicitly handle deleted user IDs by short circuiting the lookup
  logic and returning a singleton.
* The cache map is protected during HTTP requests to the Discord API.
* The nonexistence of a user is cached. This is to prevent excessive
  requests (a user can't suddenly begin existing at a given ID).

The user cache is upserted on READY, incoming messages, backfill, etc.
2026-02-06 15:43:51 -08:00
Skip R
4bdb0de559 discordid,connector: remember which guilds were bridged 2026-02-05 22:21:16 -08:00
Skip R
6adf319cfb connector: sync guild spaces via event instead of manually 2026-02-03 21:36:08 -08:00
Skip R
47095f1993 connector: instantiate http.Client from bridge settings 2026-02-03 21:00:35 -08:00
Skip R
2682175508 connector: fetch @me to create login before creating client
Creating the client before the actual UserLogin is bad form.
2026-02-02 22:52:14 -08:00
Skip R
92352ce603 discordid: remove all ID-related casts
In the same vein as mautrix-whatsapp, -slack and others, do not make
assumptions about how the ID is represented in the connector code. Let
the discordid package be entirely responsible.
2026-02-01 21:09:17 -08:00
Skip R
5e0f9b909a connector: break out guild bridging logic into method 2026-01-26 11:33:13 -08:00
Skip R
b4fdd8b9ed connector: don't crash upon less than 10 private channels 2026-01-26 11:33:13 -08:00
Skip R
7849c09443 connector: send bridge state updates on gateway events
This also makes the account properly appear in client settings after
provisioning.
2026-01-20 16:08:16 -08:00
Skip R
5b7a7a430c connector: fix log messages when downloading guild avatars 2026-01-15 15:53:17 -08:00
Skip R
f5292e6a7d connector: first pass at bridging guilds
For each guild specified in the config, create a space and bridge all
contained text channels that the user has permissions to view.

* Finally add a custom config struct where we accept a list of guild IDs
  to bridge. This is intended to be temporary as we flesh out the proper
  interfaces for managing which guilds to bridge.
* Defined a custom meta type for portals that holds the containing guild
  ID of the channel (if any).
* Transferred the responsibility of building a channel's ChatInfo and
  ChatMemberList to the DiscordChatResync event itself.
2026-01-09 19:57:17 -08:00
Skip R
86544bc7af relocate dbmeta models to discordid
While we're about to introduce more metadata structs, it seems like
mautrix-slack keeps these in slackid, so let's keep ours in discordid.
2026-01-09 17:13:15 -08:00
Skip R
fdcfb2b083 chore: bump copyright year 2026-01-08 16:56:13 -08:00
Skip R
bfebeeb7e5 handlematrix: bridge outgoing typing events 2026-01-08 16:49:27 -08:00
Skip R
8a28fa0f95 connector: share session construction logic
So we can't forget to set up the logging handler.
2026-01-07 18:51:32 -08:00
Skip R
e71075cd0d handlematrix: bridge outgoing message attachments 2026-01-05 22:29:26 -08:00
Skip R
099b464f84 client: refactor boot logic into SetUp method
This method only has heartbeat session population logic for now, so it's
actually a no-op during provisioning. However, there's probably some
value in "mandating" that clients call this shortly after construction,
so we have a chance to run any setup logic that we might need in the
future.

This _feels_ unidiomatic...?
2025-12-18 19:34:50 -08:00
Skip R
2075a4b853 client: don't nil out discordgo.Session when disconnecting
I don't have the logs anymore unfortunately, but I witnessed a
(seemingly?) rare nil dereference _within discordgo's event handling
code_ after Disconnect on the client was called (caused by SIGINT). My
thinking is that this caused the Session to get garbage collected, so
the method receiver became nil out from under it.

To let discordgo clean up after itself, keep a reference to it in the
client.
2025-12-18 19:31:40 -08:00
Skip R
60171b4fca lint 2025-12-11 19:56:31 -08:00
Skip R
506f42f93b bridge basic emoji reactions from gateway to matrix 2025-12-11 19:24:19 -08:00
Skip R
d464cb8b66 bridge discord messages to matrix 2025-12-11 18:22:36 -08:00
Skip R
b5e6db06f8 msgconv: port most of attachment and text message bridging
* Created a separate discordid package to avoid import cycles.
* Implemented attachment bridging. We still need to implement direct
  media, but this will do for now.
* Corrected how encrypted files (e.g. embed images and attachments) were
  bridged. Previously, the URL field would be empty.

Still a lot of missing pieces. Thoughts:

* Mentions to roles and custom emoji are not rendered properly. We need
  to maintain our own DB.
* We might not need the "attachments" leaf package anymore? It's just
  there to avoid an import cycle.

Bridging actual events (i.e. wiring up discordgo's event handlers) is
probably next.
2025-11-26 18:13:07 -08:00
Skip R
86e18c1f7d msgconv: port the majority of embed and attachment bridging
We still need to implement direct media support, so for now we encrypt
and reupload to Matrix. Notably remaining is conversion to HTML.
2025-11-26 15:18:29 -08:00
Skip R
17fed9aca5 msgconv: initial impl of ToMatrix, porting convertDiscordTextMessage 2025-11-25 18:01:31 -08:00
Skip R
114df5f2a2 tidy 2025-11-25 15:09:35 -08:00
Skip R
31c1cdda0c connector: sort recent private channels properly 2025-11-25 15:09:20 -08:00
Skip R
f8b65fe1f0 clarify comment 2025-11-25 14:31:42 -08:00
Skip R
61ef0c1051 connector: limit the amount of private channels initially synced
Otherwise, we'll hit the ratelimit pretty easily.
2025-11-25 14:28:28 -08:00
Skip R
ab68fae8dd connector: fix UserLogin lifecycle during provisioning
Bridge provisioning would crash because we wouldn't thread the necessary
database models through.
2025-11-25 14:27:36 -08:00
Skip R
ae98d58dbe connector: set CanBackfill on rooms 2025-11-25 13:48:48 -08:00
Skip R
aecc5234e6 remove test aggressive updates 2025-11-25 11:09:31 -08:00
Skip R
1c599a33bc add aggressive info updating for dev 2025-11-24 13:23:46 -08:00
Skip R
1442b356f2 sync channel avatars 2025-11-24 13:08:02 -08:00
Skip R
f04a8658d9 always add self when creating DM portals
Clients will leave rooms automatically when they realize that they
aren't actually members of the channel.
2025-11-24 13:07:24 -08:00
Skip R
4e41c2f227 sync private channels and their members 2025-11-24 12:42:27 -08:00
Skip R
bc13724b0a use zerolog/local loggers instead of zerolog/log 2025-11-24 11:15:58 -08:00
Skip R
586cb2bfe6 initial pass at wiring up login to discordgo 2025-11-24 11:04:40 -08:00
Tulir Asokan
4f1ae630fc Merge branch 'main' into v2 2025-11-20 10:11:42 +02:00
Tulir Asokan
0a7b8bf41b all: init v2 and delete old bridge 2024-08-15 16:44:23 +03:00