mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
Cleanup remaining statekey usage for senderIDs (#3106)
This commit is contained in:
parent
832ccc32f6
commit
77d9e4e93d
62 changed files with 760 additions and 455 deletions
|
@ -34,11 +34,11 @@ func (e ErrNotAllowed) Error() string {
|
|||
|
||||
type RestrictedJoinAPI interface {
|
||||
CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (gomatrixserverlib.PDU, error)
|
||||
InvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error)
|
||||
RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, userID spec.UserID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error)
|
||||
InvitePending(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (bool, error)
|
||||
RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error)
|
||||
QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error)
|
||||
QueryServerJoinedToRoom(ctx context.Context, req *QueryServerJoinedToRoomRequest, res *QueryServerJoinedToRoomResponse) error
|
||||
UserJoinedToRoom(ctx context.Context, roomID types.RoomNID, userID spec.UserID) (bool, error)
|
||||
UserJoinedToRoom(ctx context.Context, roomID types.RoomNID, senderID spec.SenderID) (bool, error)
|
||||
LocallyJoinedUsers(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, roomNID types.RoomNID) ([]gomatrixserverlib.PDU, error)
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ type ClientRoomserverAPI interface {
|
|||
|
||||
PerformCreateRoom(ctx context.Context, userID spec.UserID, roomID spec.RoomID, createRequest *PerformCreateRoomRequest) (string, *util.JSONResponse)
|
||||
// PerformRoomUpgrade upgrades a room to a newer version
|
||||
PerformRoomUpgrade(ctx context.Context, roomID, userID string, roomVersion gomatrixserverlib.RoomVersion) (newRoomID string, err error)
|
||||
PerformRoomUpgrade(ctx context.Context, roomID string, userID spec.UserID, roomVersion gomatrixserverlib.RoomVersion) (newRoomID string, err error)
|
||||
PerformAdminEvacuateRoom(ctx context.Context, roomID string) (affected []string, err error)
|
||||
PerformAdminEvacuateUser(ctx context.Context, userID string) (affected []string, err error)
|
||||
PerformAdminPurgeRoom(ctx context.Context, roomID string) error
|
||||
|
@ -228,6 +228,7 @@ type FederationRoomserverAPI interface {
|
|||
// QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.
|
||||
QueryServerBannedFromRoom(ctx context.Context, req *QueryServerBannedFromRoomRequest, res *QueryServerBannedFromRoomResponse) error
|
||||
QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
|
||||
QueryMembershipForSenderID(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, res *QueryMembershipForUserResponse) error
|
||||
QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
|
||||
QueryRoomVersionForRoom(ctx context.Context, roomID string) (gomatrixserverlib.RoomVersion, error)
|
||||
GetRoomIDForAlias(ctx context.Context, req *GetRoomIDForAliasRequest, res *GetRoomIDForAliasResponse) error
|
||||
|
@ -238,15 +239,13 @@ type FederationRoomserverAPI interface {
|
|||
// Takes lists of PrevEventIDs and AuthEventsIDs and uses them to calculate
|
||||
// the state and auth chain to return.
|
||||
QueryStateAndAuthChain(ctx context.Context, req *QueryStateAndAuthChainRequest, res *QueryStateAndAuthChainResponse) error
|
||||
// Query if we think we're still in a room.
|
||||
QueryServerJoinedToRoom(ctx context.Context, req *QueryServerJoinedToRoomRequest, res *QueryServerJoinedToRoomResponse) error
|
||||
QueryPublishedRooms(ctx context.Context, req *QueryPublishedRoomsRequest, res *QueryPublishedRoomsResponse) error
|
||||
// Query missing events for a room from roomserver
|
||||
QueryMissingEvents(ctx context.Context, req *QueryMissingEventsRequest, res *QueryMissingEventsResponse) error
|
||||
// Query whether a server is allowed to see an event
|
||||
QueryServerAllowedToSeeEvent(ctx context.Context, serverName spec.ServerName, eventID string) (allowed bool, err error)
|
||||
QueryServerAllowedToSeeEvent(ctx context.Context, serverName spec.ServerName, eventID string, roomID string) (allowed bool, err error)
|
||||
QueryRoomsForUser(ctx context.Context, req *QueryRoomsForUserRequest, res *QueryRoomsForUserResponse) error
|
||||
QueryRestrictedJoinAllowed(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (string, error)
|
||||
QueryRestrictedJoinAllowed(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (string, error)
|
||||
PerformInboundPeek(ctx context.Context, req *PerformInboundPeekRequest, res *PerformInboundPeekResponse) error
|
||||
HandleInvite(ctx context.Context, event *types.HeaderedEvent) error
|
||||
|
||||
|
@ -254,12 +253,6 @@ 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
|
||||
|
||||
CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (gomatrixserverlib.PDU, error)
|
||||
InvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error)
|
||||
QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error)
|
||||
UserJoinedToRoom(ctx context.Context, roomID types.RoomNID, userID spec.UserID) (bool, error)
|
||||
LocallyJoinedUsers(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, roomNID types.RoomNID) ([]gomatrixserverlib.PDU, error)
|
||||
|
||||
IsKnownRoom(ctx context.Context, roomID spec.RoomID) (bool, error)
|
||||
StateQuerier() gomatrixserverlib.StateQuerier
|
||||
}
|
||||
|
|
|
@ -215,8 +215,10 @@ type OutputNewInviteEvent struct {
|
|||
type OutputRetireInviteEvent struct {
|
||||
// The ID of the "m.room.member" invite event.
|
||||
EventID string
|
||||
// The target user ID of the "m.room.member" invite event that was retired.
|
||||
TargetUserID string
|
||||
// The room ID of the "m.room.member" invite event.
|
||||
RoomID string
|
||||
// The target sender ID of the "m.room.member" invite event that was retired.
|
||||
TargetSenderID spec.SenderID
|
||||
// Optional event ID of the event that replaced the invite.
|
||||
// This can be empty if the invite was rejected locally and we were unable
|
||||
// to reach the server that originally sent the invite.
|
||||
|
|
|
@ -41,8 +41,8 @@ type PerformJoinRequest struct {
|
|||
}
|
||||
|
||||
type PerformLeaveRequest struct {
|
||||
RoomID string `json:"room_id"`
|
||||
UserID string `json:"user_id"`
|
||||
RoomID string
|
||||
Leaver spec.UserID
|
||||
}
|
||||
|
||||
type PerformLeaveResponse struct {
|
||||
|
|
|
@ -113,9 +113,9 @@ type QueryEventsByIDResponse struct {
|
|||
// QueryMembershipForUserRequest is a request to QueryMembership
|
||||
type QueryMembershipForUserRequest struct {
|
||||
// ID of the room to fetch membership from
|
||||
RoomID string `json:"room_id"`
|
||||
RoomID string
|
||||
// ID of the user for whom membership is requested
|
||||
UserID string `json:"user_id"`
|
||||
UserID spec.UserID
|
||||
}
|
||||
|
||||
// QueryMembershipForUserResponse is a response to QueryMembership
|
||||
|
@ -145,7 +145,7 @@ type QueryMembershipsForRoomRequest struct {
|
|||
// Optional - ID of the user sending the request, for checking if the
|
||||
// user is allowed to see the memberships. If not specified then all
|
||||
// room memberships will be returned.
|
||||
Sender string `json:"sender"`
|
||||
SenderID spec.SenderID `json:"sender"`
|
||||
}
|
||||
|
||||
// QueryMembershipsForRoomResponse is a response to QueryMembershipsForRoom
|
||||
|
@ -448,11 +448,11 @@ func (rq *JoinRoomQuerier) CurrentStateEvent(ctx context.Context, roomID spec.Ro
|
|||
return rq.Roomserver.CurrentStateEvent(ctx, roomID, eventType, stateKey)
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) InvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error) {
|
||||
return rq.Roomserver.InvitePending(ctx, roomID, userID)
|
||||
func (rq *JoinRoomQuerier) InvitePending(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (bool, error) {
|
||||
return rq.Roomserver.InvitePending(ctx, roomID, senderID)
|
||||
}
|
||||
|
||||
func (rq *JoinRoomQuerier) RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, userID spec.UserID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error) {
|
||||
func (rq *JoinRoomQuerier) RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error) {
|
||||
roomInfo, err := rq.Roomserver.QueryRoomInfo(ctx, roomID)
|
||||
if err != nil || roomInfo == nil || roomInfo.IsStub() {
|
||||
return nil, err
|
||||
|
@ -468,7 +468,7 @@ func (rq *JoinRoomQuerier) RestrictedRoomJoinInfo(ctx context.Context, roomID sp
|
|||
return nil, fmt.Errorf("InternalServerError: Failed to query room: %w", err)
|
||||
}
|
||||
|
||||
userJoinedToRoom, err := rq.Roomserver.UserJoinedToRoom(ctx, types.RoomNID(roomInfo.RoomNID), userID)
|
||||
userJoinedToRoom, err := rq.Roomserver.UserJoinedToRoom(ctx, types.RoomNID(roomInfo.RoomNID), senderID)
|
||||
if err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("rsAPI.UserJoinedToRoom failed")
|
||||
return nil, fmt.Errorf("InternalServerError: %w", err)
|
||||
|
@ -492,12 +492,8 @@ type MembershipQuerier struct {
|
|||
}
|
||||
|
||||
func (mq *MembershipQuerier) CurrentMembership(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (string, error) {
|
||||
req := QueryMembershipForUserRequest{
|
||||
RoomID: roomID.String(),
|
||||
UserID: string(senderID),
|
||||
}
|
||||
res := QueryMembershipForUserResponse{}
|
||||
err := mq.Roomserver.QueryMembershipForUser(ctx, &req, &res)
|
||||
err := mq.Roomserver.QueryMembershipForSenderID(ctx, roomID, senderID, &res)
|
||||
|
||||
membership := ""
|
||||
if err == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue