Skip to content

Commit 5c5745e

Browse files
committed
feat: local bridge support
1 parent 1bff055 commit 5c5745e

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

pkg/connector/connector.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ func (lc *LineConnector) Init(bridge *bridgev2.Bridge) {
4141
lc.br = bridge
4242
}
4343

44-
func (lc *LineConnector) Start(ctx context.Context) error {
45-
_, ok := lc.br.Matrix.(bridgev2.MatrixConnectorWithServer)
46-
if !ok {
47-
return fmt.Errorf("matrix connector does not implement MatrixConnectorWithServer")
48-
}
44+
func (lc *LineConnector) Start(context.Context) error {
4945
return nil
5046
}
5147

@@ -88,7 +84,7 @@ func (lc *LineConnector) GetName() bridgev2.BridgeName {
8884
NetworkURL: "https://line.me",
8985
NetworkIcon: "",
9086
NetworkID: "line",
91-
BeeperBridgeType: "github.com/highesttt/matrix-line-messenger",
87+
BeeperBridgeType: "line",
9288
DefaultPort: 29322,
9389
}
9490
}

pkg/connector/connector_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,31 @@ func TestInitDisablesManagementRoomBridgeStatusNotices(t *testing.T) {
8787
}
8888
}
8989

90+
func TestStartSupportsMatrixConnectorWithoutServer(t *testing.T) {
91+
matrix := &bridgeStateTestMatrix{}
92+
if _, ok := any(matrix).(bridgev2.MatrixConnectorWithServer); ok {
93+
t.Fatal("test Matrix connector unexpectedly implements MatrixConnectorWithServer")
94+
}
95+
96+
bridge := &bridgev2.Bridge{
97+
Config: &bridgeconfig.BridgeConfig{},
98+
Matrix: matrix,
99+
}
100+
connector := &LineConnector{}
101+
connector.Init(bridge)
102+
103+
if err := connector.Start(context.Background()); err != nil {
104+
t.Fatalf("Start rejected a Matrix connector without a server: %v", err)
105+
}
106+
}
107+
108+
func TestGetNameUsesCanonicalBeeperBridgeType(t *testing.T) {
109+
name := (&LineConnector{}).GetName()
110+
if name.BeeperBridgeType != "line" {
111+
t.Fatalf("BeeperBridgeType = %q, want line", name.BeeperBridgeType)
112+
}
113+
}
114+
90115
func TestBridgeStateUpdatesDoNotUseManagementRoom(t *testing.T) {
91116
tests := map[string]id.RoomID{
92117
"room must not be created": "",

0 commit comments

Comments
 (0)