Commit Graph

106 Commits

Author SHA1 Message Date
Skip R
aba6f5aafc dbmeta: merge incoming metadata
By not implementing MetaMerger, UserLogin metadata such as
BridgedGuildIDs would get clobbered upon reauthing because the metadata
was replaced entirely. Implement CopyFrom so we can gain deeper control
over what is preserved upon reauth. Notably, preserve BridgedGuildIDs so
we can't get into a weird state where a guild is bridged but
simultaneously absent from BridgedGuildIDs, which would cause us to not
subscribe (OP 14) to it properly.
2026-02-11 19:33:46 -08:00
Skip R
6407a3e3e0 connector: set up provisioning in Start instead of Init
Doing it in Init happens to work for local bridges, but not when
connecting to a remote Matrix homeserver.
2026-02-11 19:23:33 -08:00
Skip R
40ae884e7f connector/client: refactor guild subscription, push log onto context 2026-02-11 19:23:19 -08:00
Skip R
07ba87f9d6 handlediscord: bridge guild delete 2026-02-11 17:42:25 -08:00
Skip R
82aab381ab handlediscord: bridge message edits 2026-02-09 18:04:23 -08:00
Skip R
c8561de9c4 connector: panic with a more useful message when creating nil sender 2026-02-09 15:05:07 -08:00
Skip R
9013e01b49 handlediscord: bridge message deletes 2026-02-09 15:04:47 -08:00
Skip R
7a6f59ad73 handlematrix: bridge message edits 2026-02-09 15:04:33 -08:00
Skip R
2ddba507c2 connector/capabilities: clean up stale comments 2026-02-09 14:34:11 -08:00
Skip R
abcc0dca47 msgconv/from-discord: port sticker conversion 2026-02-09 14:13:54 -08:00
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
1fcc910184 msgconv/from-discord: add per-message profiles 2026-02-06 17:42:51 -08:00
Skip R
808993c174 backfill: update ghosts as we backfill 2026-02-06 17:42:09 -08:00
Skip R
a1d4c4cb28 usercache: return user ids that were updated 2026-02-06 17:41:54 -08:00
Skip R
ce6404ac78 backfill: attach sublogger to context 2026-02-06 17:36:26 -08:00
Skip R
7cfa17023b userinfo: use username as ghost identifier instead of user id
This is more correct.
2026-02-06 15:43:51 -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
c611e8f116 connector: tell discordgo to not track presences/voice state 2026-02-06 13:37:45 -08:00
Skip R
a7ae544999 provisioning: improve compat with beeper desktop 2026-02-05 22:48:36 -08:00
Skip R
4f420c4662 provisioning: preserve logger context 2026-02-05 22:22:13 -08:00
Skip R
4bdb0de559 discordid,connector: remember which guilds were bridged 2026-02-05 22:21:16 -08:00
Skip R
869d8c5412 handlematrix: actually use the qualified emoji when reacting
By accessing reaction.Content.RelatesTo.Key we bypass the work done in
PreHandleMatrixReaction.
2026-02-04 12:44:33 -08:00
Skip R
094bc9bd77 connector: support transaction IDs 2026-02-03 22:03:29 -08:00
Skip R
6adf319cfb connector: sync guild spaces via event instead of manually 2026-02-03 21:36:08 -08:00
Skip R
9dfc91ff14 handlematrix: fully qualify reaction emojis 2026-02-03 21:07:51 -08:00
Skip R
47095f1993 connector: instantiate http.Client from bridge settings 2026-02-03 21:00:35 -08:00
Skip R
1900993acd connector/login: remove custom LoadUserLogin
Consolidate how we construct `DiscordClient` by always going through the
connector's `LoadUserLogin` method.
2026-02-03 20:44:38 -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
8c02a80f85 connector/login: return browser login method as the first one
clients will prefer it
2026-02-01 21:10:33 -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
Tulir Asokan
e7554b212f msgconv/attachments: don't fail if mimeless file has less than 512 bytes 2026-01-28 17:37:34 +02:00
Tulir Asokan
7d26eae8e5 login: fix flow IDs 2026-01-28 17:21:19 +02:00
Tulir Asokan
d89746d099 msgconv: clean up reuploading attachments to Matrix 2026-01-28 17:21:19 +02:00
Skip R
1a3144d2d0 msgconv/from-discord: bridge replies 2026-01-27 22:29:55 -08:00
Skip R
b8a01bf9d4 msgconv/from-discord: use a tagged switch instead of if 2026-01-27 19:12:26 -08:00
Skip R
578030a9dd msgconv/from-discord: only complain about portal when we can't find it 2026-01-27 19:11:57 -08:00
Skip R
2f8de6635a msgconv/from-discord: refactor forwarded message conversion 2026-01-27 19:10:58 -08:00
Skip R
138c77c34e provisioning: sketch out implementation
for now, this is completely unauthenticated
2026-01-26 11:33:13 -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
ac338ee722 msgconv: correctly bridge attachments and embeds
`URL` needs to be set if the room/attachment is unencrypted; otherwise,
`File` needs to be set.
2026-01-14 18:07:15 -08:00
Skip R
bdbfd661a2 msgconv: don't set EncryptedFile if there isn't one
FIXME: This probably isn't proper handling, but this is enough to
prevent panics.
2026-01-13 14:50:35 -08:00
Skip R
3d59a0eb3f login/remoteauth: tolerate multiple attempts to cancel
This will otherwise panic.
2026-01-13 14:50:12 -08:00
Skip R
e38998e68b connector: don't store config as pointer 2026-01-13 14:49:15 -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