Skip to content

PerformJoin can't use fclient.FederationClient as FederatedJoinClient #461

Description

@turt2live

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

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions