aboutsummaryrefslogtreecommitdiff
path: root/roomserver/api
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2023-06-06 20:55:18 +0000
committerGitHub <noreply@github.com>2023-06-06 20:55:18 +0000
commit7a1fd7f512ce06a472a2051ee63eae4a270eb71a (patch)
tree20128b0d3f7c69dd776aa7b2b9bc3194dda7dd75 /roomserver/api
parent725ff5567d2a3bc9992b065e72ccabefb595ec1c (diff)
PDU Sender split (#3100)
Initial cut of splitting PDU Sender into SenderID & looking up UserID where required.
Diffstat (limited to 'roomserver/api')
-rw-r--r--roomserver/api/alias.go2
-rw-r--r--roomserver/api/api.go12
-rw-r--r--roomserver/api/query.go4
3 files changed, 15 insertions, 3 deletions
diff --git a/roomserver/api/alias.go b/roomserver/api/alias.go
index 37892a44..1b947540 100644
--- a/roomserver/api/alias.go
+++ b/roomserver/api/alias.go
@@ -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"`
}
diff --git a/roomserver/api/api.go b/roomserver/api/api.go
index a37ade3a..d61a0553 100644
--- a/roomserver/api/api.go
+++ b/roomserver/api/api.go
@@ -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
diff --git a/roomserver/api/query.go b/roomserver/api/query.go
index e741c140..d79dcebb 100644
--- a/roomserver/api/query.go
+++ b/roomserver/api/query.go
@@ -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)