PDU Sender split (#3100)

Initial cut of splitting PDU Sender into SenderID & looking up UserID where required.
This commit is contained in:
devonh 2023-06-06 20:55:18 +00:00 committed by GitHub
parent 725ff5567d
commit 7a1fd7f512
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 580 additions and 189 deletions

View file

@ -62,7 +62,7 @@ type GetAliasesForRoomIDResponse struct {
// RemoveRoomAliasRequest is a request to RemoveRoomAlias
type RemoveRoomAliasRequest struct {
// ID of the user removing the alias
UserID string `json:"user_id"`
SenderID string `json:"user_id"`
// The room alias to remove
Alias string `json:"alias"`
}

View file

@ -49,6 +49,7 @@ type RoomserverInternalAPI interface {
ClientRoomserverAPI
UserRoomserverAPI
FederationRoomserverAPI
QuerySenderIDAPI
// needed to avoid chicken and egg scenario when setting up the
// interdependencies between the roomserver and other input APIs
@ -75,6 +76,11 @@ type InputRoomEventsAPI interface {
)
}
type QuerySenderIDAPI interface {
QuerySenderIDForUser(ctx context.Context, roomID string, userID spec.UserID) (string, error)
QueryUserIDForSender(ctx context.Context, roomID string, senderID string) (*spec.UserID, error)
}
// Query the latest events and state for a room from the room server.
type QueryLatestEventsAndStateAPI interface {
QueryLatestEventsAndState(ctx context.Context, req *QueryLatestEventsAndStateRequest, res *QueryLatestEventsAndStateResponse) error
@ -102,6 +108,7 @@ type QueryEventsAPI interface {
type SyncRoomserverAPI interface {
QueryLatestEventsAndStateAPI
QueryBulkStateContentAPI
QuerySenderIDAPI
// QuerySharedUsers returns a list of users who share at least 1 room in common with the given user.
QuerySharedUsers(ctx context.Context, req *QuerySharedUsersRequest, res *QuerySharedUsersResponse) error
// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
@ -142,6 +149,7 @@ type SyncRoomserverAPI interface {
}
type AppserviceRoomserverAPI interface {
QuerySenderIDAPI
// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
// which room to use by querying the first events roomID.
QueryEventsByID(
@ -168,6 +176,7 @@ type ClientRoomserverAPI interface {
QueryLatestEventsAndStateAPI
QueryBulkStateContentAPI
QueryEventsAPI
QuerySenderIDAPI
QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
QueryRoomsForUser(ctx context.Context, req *QueryRoomsForUserRequest, res *QueryRoomsForUserResponse) error
@ -200,6 +209,7 @@ type ClientRoomserverAPI interface {
}
type UserRoomserverAPI interface {
QuerySenderIDAPI
QueryLatestEventsAndStateAPI
KeyserverRoomserverAPI
QueryCurrentState(ctx context.Context, req *QueryCurrentStateRequest, res *QueryCurrentStateResponse) error
@ -213,6 +223,8 @@ type FederationRoomserverAPI interface {
InputRoomEventsAPI
QueryLatestEventsAndStateAPI
QueryBulkStateContentAPI
QuerySenderIDAPI
// 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

View file

@ -491,10 +491,10 @@ type MembershipQuerier struct {
Roomserver FederationRoomserverAPI
}
func (mq *MembershipQuerier) CurrentMembership(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (string, error) {
func (mq *MembershipQuerier) CurrentMembership(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (string, error) {
req := QueryMembershipForUserRequest{
RoomID: roomID.String(),
UserID: userID.String(),
UserID: string(senderID),
}
res := QueryMembershipForUserResponse{}
err := mq.Roomserver.QueryMembershipForUser(ctx, &req, &res)