mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-12 08:33:10 -06:00
Dont pass roomid/userid by pointer
This commit is contained in:
parent
d039f9a506
commit
72d72e89df
|
|
@ -38,7 +38,7 @@ type JoinRoomQuerier struct {
|
|||
roomserver api.FederationRoomserverAPI
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) RoomInfo(ctx context.Context, roomID *spec.RoomID) (*gomatrixserverlib.RoomInfo, error) {
|
||||
func (rq *JoinRoomQuerier) RoomInfo(ctx context.Context, roomID spec.RoomID) (*gomatrixserverlib.RoomInfo, error) {
|
||||
roomInfo, err := rq.roomserver.QueryRoomInfo(ctx, roomID)
|
||||
var result *gomatrixserverlib.RoomInfo
|
||||
if roomInfo != nil && !roomInfo.IsStub() {
|
||||
|
|
@ -51,11 +51,11 @@ func (rq *JoinRoomQuerier) RoomInfo(ctx context.Context, roomID *spec.RoomID) (*
|
|||
return result, err
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) StateEvent(ctx context.Context, roomID *spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error) {
|
||||
func (rq *JoinRoomQuerier) StateEvent(ctx context.Context, roomID spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error) {
|
||||
return rq.roomserver.GetStateEvent(ctx, roomID, eventType, stateKey)
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) ServerInRoom(ctx context.Context, server spec.ServerName, roomID *spec.RoomID) (*gomatrixserverlib.JoinedToRoomResponse, error) {
|
||||
func (rq *JoinRoomQuerier) ServerInRoom(ctx context.Context, server spec.ServerName, roomID spec.RoomID) (*gomatrixserverlib.JoinedToRoomResponse, error) {
|
||||
req := api.QueryServerJoinedToRoomRequest{
|
||||
ServerName: server,
|
||||
RoomID: roomID.String(),
|
||||
|
|
@ -73,7 +73,7 @@ func (rq *JoinRoomQuerier) ServerInRoom(ctx context.Context, server spec.ServerN
|
|||
return &joinedResponse, nil
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) Membership(ctx context.Context, roomNID int64, userID *spec.UserID) (bool, error) {
|
||||
func (rq *JoinRoomQuerier) Membership(ctx context.Context, roomNID int64, userID spec.UserID) (bool, error) {
|
||||
return rq.roomserver.IsInRoom(ctx, types.RoomNID(roomNID), userID)
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ func (rq *JoinRoomQuerier) GetJoinedUsers(ctx context.Context, roomVersion gomat
|
|||
return rq.roomserver.GetLocallyJoinedUsers(ctx, roomVersion, types.RoomNID(roomNID))
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) InvitePending(ctx context.Context, roomID *spec.RoomID, userID *spec.UserID) (bool, error) {
|
||||
func (rq *JoinRoomQuerier) InvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error) {
|
||||
return rq.roomserver.IsInvitePending(ctx, roomID, userID)
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ func MakeJoin(
|
|||
request *fclient.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID *spec.RoomID, userID *spec.UserID,
|
||||
roomID spec.RoomID, userID spec.UserID,
|
||||
remoteVersions []gomatrixserverlib.RoomVersion,
|
||||
) util.JSONResponse {
|
||||
roomVersion, err := rsAPI.QueryRoomVersionForRoom(httpReq.Context(), roomID.String())
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ func Setup(
|
|||
|
||||
logrus.Debugf("Processing make_join for user %s, room %s", userID.String(), roomID.String())
|
||||
return MakeJoin(
|
||||
httpReq, request, cfg, rsAPI, roomID, userID, remoteVersions,
|
||||
httpReq, request, cfg, rsAPI, *roomID, *userID, remoteVersions,
|
||||
)
|
||||
},
|
||||
)).Methods(http.MethodGet)
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
|||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230511034638-a7c5b3ffed1a
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230512162258-bdb2e94f6b1f
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -323,8 +323,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 h1:s7fexw
|
|||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230511034638-a7c5b3ffed1a h1:akYgYSM8RWlEFM7y4o5i/9hSq85d8xgngyStcLJIRxM=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230511034638-a7c5b3ffed1a/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230512162258-bdb2e94f6b1f h1:IUoNmx4LOnLA7iHmD4JFfPlcPqH6DM/oQOL3bmbSaBs=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230512162258-bdb2e94f6b1f/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
||||
|
|
|
|||
|
|
@ -226,10 +226,10 @@ type FederationRoomserverAPI interface {
|
|||
// Query a given amount (or less) of events prior to a given set of events.
|
||||
PerformBackfill(ctx context.Context, req *PerformBackfillRequest, res *PerformBackfillResponse) error
|
||||
|
||||
IsInvitePending(ctx context.Context, roomID *spec.RoomID, userID *spec.UserID) (bool, error)
|
||||
QueryRoomInfo(ctx context.Context, roomID *spec.RoomID) (*types.RoomInfo, error)
|
||||
GetStateEvent(ctx context.Context, roomID *spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error)
|
||||
IsInRoom(ctx context.Context, roomID types.RoomNID, userID *spec.UserID) (bool, error)
|
||||
IsInvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error)
|
||||
QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error)
|
||||
GetStateEvent(ctx context.Context, roomID spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error)
|
||||
IsInRoom(ctx context.Context, roomID types.RoomNID, userID spec.UserID) (bool, error)
|
||||
GetLocallyJoinedUsers(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, roomNID types.RoomNID) ([]gomatrixserverlib.PDU, error)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -858,20 +858,20 @@ func (r *Queryer) QueryAuthChain(ctx context.Context, req *api.QueryAuthChainReq
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Queryer) IsInvitePending(ctx context.Context, roomID *spec.RoomID, userID *spec.UserID) (bool, error) {
|
||||
func (r *Queryer) IsInvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error) {
|
||||
pending, _, _, _, err := helpers.IsInvitePending(ctx, r.DB, roomID.String(), userID.String())
|
||||
return pending, err
|
||||
}
|
||||
|
||||
func (r *Queryer) QueryRoomInfo(ctx context.Context, roomID *spec.RoomID) (*types.RoomInfo, error) {
|
||||
func (r *Queryer) QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error) {
|
||||
return r.DB.RoomInfo(ctx, roomID.String())
|
||||
}
|
||||
|
||||
func (r *Queryer) GetStateEvent(ctx context.Context, roomID *spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error) {
|
||||
func (r *Queryer) GetStateEvent(ctx context.Context, roomID spec.RoomID, eventType spec.MatrixEventType, stateKey string) (gomatrixserverlib.PDU, error) {
|
||||
return r.DB.GetStateEvent(ctx, roomID.String(), string(eventType), "")
|
||||
}
|
||||
|
||||
func (r *Queryer) IsInRoom(ctx context.Context, roomNID types.RoomNID, userID *spec.UserID) (bool, error) {
|
||||
func (r *Queryer) IsInRoom(ctx context.Context, roomNID types.RoomNID, userID spec.UserID) (bool, error) {
|
||||
_, isIn, _, err := r.DB.GetMembership(ctx, roomNID, userID.String())
|
||||
return isIn, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue