Repository navigation
Add initial draft - #1
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Direct-room state handling and callback concurrency currently produce incorrect and potentially racy behavior.
6 open findings
Serialize Ready with other handler callbacks · New Persist m.direct updates when creating direct rooms · New Rebuild direct-room state from m.direct snapshots · New Preserve cached member profiles when adding direct rooms · New Register channels for ordinary membership events · New Store room names separately from canonical aliases · New
What changed in this PR
Introduces the initial Matrix client library for matterircd/matterbridge.
Changes:
- Adds login, synchronization, room/user tracking, and messaging.
- Defines event handlers and public data types.
- Adds dependencies, licensing, lint configuration, and CI.
| File | Description |
|---|---|
client.go |
Implements the Matrix client API and sync lifecycle. |
handlers.go |
Processes room state, messages, reactions, and direct chats. |
types.go |
Defines credentials, entities, and handler interfaces. |
go.mod |
Declares the module and dependencies. |
go.sum |
Locks dependency checksums. |
.golangci.yaml |
Configures Go linting and formatting. |
.github/workflows/development.yml |
Runs lint checks in CI. |
LICENSE |
Adds the Apache 2.0 license. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| c.register(syncer) | ||
|
|
||
| go c.syncLoop() | ||
| go c.waitReady() |
Comment on lines
+291
to
+293
| c.Lock() | ||
| c.dmChannels[roomID] = []id.UserID{userID} | ||
| c.Unlock() |
Comment on lines
+47
to
+49
| for userID, rooms := range *chats { | ||
| for _, roomID := range rooms { | ||
| c.addDirectLocked(roomID, userID, &event.MemberEventContent{}) |
|
|
||
| for userID, rooms := range *chats { | ||
| for _, roomID := range rooms { | ||
| c.addDirectLocked(roomID, userID, &event.MemberEventContent{}) |
| c.Lock() | ||
| defer c.Unlock() | ||
|
|
||
| u, ok := c.users[targetID] |
| ch := c.channelLocked(ev.RoomID) | ||
|
|
||
| ch.Lock() | ||
| ch.Alias, ch.AltAliases = alias.Alias, alias.AltAliases |
hloeung
marked this pull request as ready for review
October 11, 2026 20:09
Contributor
Author
|
Follow up PR addressing the issues identifed by Copilot - #2 |
hloeung
added a commit
that referenced
this pull request
Oct 11, 2026
…ient (#2) Addresses the six Copilot review comments on the initial draft (#1) and makes logging consistent with `matterclient`, using logrus with the `matterbridge/logrus-prefixed-formatter`. - **Ready / handler serialization** - `Ready` is no longer fired from a separate timer goroutine. A `readySyncer` wrapper around `DefaultSyncer` calls it once, on the sync goroutine, after the first sync response has been fully processed. - This keeps `Ready`, `OnMessage` and `OnReaction` serialized as the `Handler` contract says. - **Direct rooms** - `SendDirect` now persists the updated `m.direct` account data via `SetAccountData`. Previously the new room existed only in memory, so a relogin could create a duplicate. - If persisting fails, the error is logged and the message is still sent. Returning the error would invite a retry that creates another room. - `handleDM` treats `m.direct` as a full snapshot. It rebuilds `dmChannels` and clears `IsDirect` on rooms that were removed. - Registering a direct room no longer overwrites a cached member profile, so `DisplayName` doesn't regress to empty. - **Rooms** - Membership events now create the `Channel` and maintain its `Members`, so unnamed joined rooms show up in `Rooms()`. - `Channel` gets a separate `Name` field. `Rooms()` resolves the alias first, then the name, then the room ID. Clearing the canonical alias no longer discards the room name. - **Logging** - `New` builds two logrus loggers with the prefixed formatter, as matterclient does: - `matrixclient` with padding 13. - `matrixclient: API` with padding 18, at error level. - Sync errors go through the API logger. - The formatter dependency is added to `go.mod` and `go.sum`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.