matrix-org / matrix-org/gomatrixserverlib

`PerformJoin` can't use `fclient.FederationClient` as `FederatedJoinClient`

Open
#461 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
67
Forks
60
PR merge metrics
No merged PRs in 30d

Description

This is due to the `MakeJoin` and `SendJoin` functions returning pointer-less responses. To work around this, one must do something like the following:

```go
type internalJoinClient struct {
upstream fclient.FederationClient
}

func (c *internalJoinClient) MakeJoin(ctx context.Context, origin spec.ServerName, via spec.ServerName, roomId string, userId string) (gomatrixserverlib.MakeJoinResponse, error) {
res, err := c.upstream.MakeJoin(ctx, origin, via, roomId, userId)
return &res, err
}

func (c *internalJoinClient) SendJoin(ctx context.Context, origin spec.ServerName, via spec.ServerName, event gomatrixserverlib.PDU) (gomatrixserverlib.SendJoinResponse, error) {
res, err := c.upstream.SendJoin(ctx, origin, via, event)
return &res, err
}
```

then, the `PerformJoin` function can be used as such:

```go
client := fclient.NewFederationClient( /* ... */ ) // or wherever you get your client from
join, err := gomatrixserverlib.PerformJoin(ctx, &internalJoinClient{upstream: client}, gomatrixserverlib.PerformJoinInput{ /* ... */ })
// etc
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PerformJoin entry point and the FederatedJoinClient interface, then compare their MakeJoin and SendJoin signatures with fclient.FederationClient. Confirm the pointer-versus-value response mismatch and inspect any related interface tests. Done means a FederationClient can be passed to PerformJoin without the adapter shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design, distributed-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.