mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 05:12:46 +00:00
Implement forgetting about rooms (#1572)
* Add basic storage methods * Add internal api handler * Add check for forgotten room * Add /rooms/{roomID}/forget endpoint * Add missing rsAPI method * Remove unused parameters * Add passing tests Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Add missing file * Add postgres migration * Add sqlite migration * Use Forgetter to forget room * Remove empty line * Update HTTP status codes It looks like the spec calls for these to be 400, rather than 403: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-forget Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
parent
2ce2112ddb
commit
eccd0d2c1b
25 changed files with 543 additions and 136 deletions
|
@ -147,6 +147,9 @@ type RoomserverInternalAPI interface {
|
|||
response *PerformBackfillResponse,
|
||||
) error
|
||||
|
||||
// PerformForget forgets a rooms history for a specific user
|
||||
PerformForget(ctx context.Context, req *PerformForgetRequest, resp *PerformForgetResponse) error
|
||||
|
||||
// Asks for the default room version as preferred by the server.
|
||||
QueryRoomVersionCapabilities(
|
||||
ctx context.Context,
|
||||
|
|
|
@ -194,6 +194,16 @@ func (t *RoomserverInternalAPITrace) PerformBackfill(
|
|||
return err
|
||||
}
|
||||
|
||||
func (t *RoomserverInternalAPITrace) PerformForget(
|
||||
ctx context.Context,
|
||||
req *PerformForgetRequest,
|
||||
res *PerformForgetResponse,
|
||||
) error {
|
||||
err := t.Impl.PerformForget(ctx, req, res)
|
||||
util.GetLogger(ctx).WithError(err).Infof("PerformForget req=%+v res=%+v", js(req), js(res))
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *RoomserverInternalAPITrace) QueryRoomVersionCapabilities(
|
||||
ctx context.Context,
|
||||
req *QueryRoomVersionCapabilitiesRequest,
|
||||
|
|
|
@ -159,3 +159,11 @@ type PerformPublishResponse struct {
|
|||
// If non-nil, the publish request failed. Contains more information why it failed.
|
||||
Error *PerformError
|
||||
}
|
||||
|
||||
// PerformForgetRequest is a request to PerformForget
|
||||
type PerformForgetRequest struct {
|
||||
RoomID string `json:"room_id"`
|
||||
UserID string `json:"user_id"`
|
||||
}
|
||||
|
||||
type PerformForgetResponse struct{}
|
||||
|
|
|
@ -140,7 +140,9 @@ type QueryMembershipForUserResponse struct {
|
|||
// True if the user is in room.
|
||||
IsInRoom bool `json:"is_in_room"`
|
||||
// The current membership
|
||||
Membership string
|
||||
Membership string `json:"membership"`
|
||||
// True if the user asked to forget this room.
|
||||
IsRoomForgotten bool `json:"is_room_forgotten"`
|
||||
}
|
||||
|
||||
// QueryMembershipsForRoomRequest is a request to QueryMembershipsForRoom
|
||||
|
@ -160,6 +162,8 @@ type QueryMembershipsForRoomResponse struct {
|
|||
// True if the user has been in room before and has either stayed in it or
|
||||
// left it.
|
||||
HasBeenInRoom bool `json:"has_been_in_room"`
|
||||
// True if the user asked to forget this room.
|
||||
IsRoomForgotten bool `json:"is_room_forgotten"`
|
||||
}
|
||||
|
||||
// QueryServerJoinedToRoomRequest is a request to QueryServerJoinedToRoom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue