aboutsummaryrefslogtreecommitdiff
path: root/roomserver/api
diff options
context:
space:
mode:
authorSam Wedgwood <28223854+swedgwood@users.noreply.github.com>2023-07-31 14:39:41 +0100
committerGitHub <noreply@github.com>2023-07-31 14:39:41 +0100
commitaf13fa1c7554fbed802d51421163f81b5b3fbe0d (patch)
treef1cbc9ba1950aef0b0a5a7651ecb80be42828415 /roomserver/api
parent3f727485d6e21a603e4df1cb31c3795cc1023caa (diff)
[pseudoIDs] Fixes for room alias tests (#3159)
Some (deceptively) simple fixes for some bugs that caused room alias tests to fail (sytext `tests/30rooms/05aliases.pl`). Each commit has details about what it fixes. Sytest results: - Sytest before (79d4a0e): https://gist.github.com/swedgwood/972ac4ef93edd130d3db0930703d6c82 - Sytest after (4b09bed): https://gist.github.com/swedgwood/504b00ac4ee892acb757b7fac55fa28a Room aliases go from `8/15` to `15/15`, but looks like these fixes also managed to fix about `4` other tests, which is a nice bonus :) Signed-off-by: `Sam Wedgwood <sam@wedgwood.dev>`
Diffstat (limited to 'roomserver/api')
-rw-r--r--roomserver/api/alias.go34
-rw-r--r--roomserver/api/api.go15
2 files changed, 13 insertions, 36 deletions
diff --git a/roomserver/api/alias.go b/roomserver/api/alias.go
index c091cf6a..6269d0b0 100644
--- a/roomserver/api/alias.go
+++ b/roomserver/api/alias.go
@@ -16,26 +16,8 @@ package api
import (
"regexp"
-
- "github.com/matrix-org/gomatrixserverlib/spec"
)
-// SetRoomAliasRequest is a request to SetRoomAlias
-type SetRoomAliasRequest struct {
- // ID of the user setting the alias
- UserID string `json:"user_id"`
- // New alias for the room
- Alias string `json:"alias"`
- // The room ID the alias is referring to
- RoomID string `json:"room_id"`
-}
-
-// SetRoomAliasResponse is a response to SetRoomAlias
-type SetRoomAliasResponse struct {
- // Does the alias already refer to a room?
- AliasExists bool `json:"alias_exists"`
-}
-
// GetRoomIDForAliasRequest is a request to GetRoomIDForAlias
type GetRoomIDForAliasRequest struct {
// Alias we want to lookup
@@ -63,22 +45,6 @@ type GetAliasesForRoomIDResponse struct {
Aliases []string `json:"aliases"`
}
-// RemoveRoomAliasRequest is a request to RemoveRoomAlias
-type RemoveRoomAliasRequest struct {
- // ID of the user removing the alias
- SenderID spec.SenderID `json:"user_id"`
- // The room alias to remove
- Alias string `json:"alias"`
-}
-
-// RemoveRoomAliasResponse is a response to RemoveRoomAlias
-type RemoveRoomAliasResponse struct {
- // Did the alias exist before?
- Found bool `json:"found"`
- // Did we remove it?
- Removed bool `json:"removed"`
-}
-
type AliasEvent struct {
Alias string `json:"alias"`
AltAliases []string `json:"alt_aliases"`
diff --git a/roomserver/api/api.go b/roomserver/api/api.go
index 28b381d3..ed87ce93 100644
--- a/roomserver/api/api.go
+++ b/roomserver/api/api.go
@@ -237,8 +237,19 @@ type ClientRoomserverAPI interface {
PerformPublish(ctx context.Context, req *PerformPublishRequest) error
// PerformForget forgets a rooms history for a specific user
PerformForget(ctx context.Context, req *PerformForgetRequest, resp *PerformForgetResponse) error
- SetRoomAlias(ctx context.Context, req *SetRoomAliasRequest, res *SetRoomAliasResponse) error
- RemoveRoomAlias(ctx context.Context, req *RemoveRoomAliasRequest, res *RemoveRoomAliasResponse) error
+
+ // Sets a room alias, as provided sender, pointing to the provided room ID.
+ //
+ // If err is nil, then the returned boolean indicates if the alias is already in use.
+ // If true, then the alias has not been set to the provided room, as it already in use.
+ SetRoomAlias(ctx context.Context, senderID spec.SenderID, roomID spec.RoomID, alias string) (aliasAlreadyExists bool, err error)
+
+ //RemoveRoomAlias(ctx context.Context, req *RemoveRoomAliasRequest, res *RemoveRoomAliasResponse) error
+ // Removes a room alias, as provided sender.
+ //
+ // Returns whether the alias was found, whether it was removed, and an error (if any occurred)
+ RemoveRoomAlias(ctx context.Context, senderID spec.SenderID, alias string) (aliasFound bool, aliasRemoved bool, err error)
+
SigningIdentityFor(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)
}