Add/Implement QueryRoomReceipts

This commit is contained in:
Till Faelligen 2020-10-13 17:35:48 +02:00
parent 5b53b7c80b
commit 615c729775
4 changed files with 45 additions and 5 deletions

View file

@ -196,5 +196,17 @@ type RoomserverInternalAPI interface {
response *RemoveRoomAliasResponse,
) error
PerformUserReceiptUpdate(ctx context.Context, req *PerformUserReceiptUpdateRequest, res *PerformUserReceiptUpdateResponse) error
// Inserts/updates a user receipt
PerformUserReceiptUpdate(
ctx context.Context,
req *PerformUserReceiptUpdateRequest,
res *PerformUserReceiptUpdateResponse,
) error
// Gets user receipts for a room
QueryRoomReceipts(
ctx context.Context,
req *QueryRoomReceiptRequest,
res *QueryRoomReceiptResponse,
) error
}

View file

@ -322,3 +322,9 @@ func (t *RoomserverInternalAPITrace) PerformUserReceiptUpdate(
util.GetLogger(ctx).WithError(err).Infof("PerformUserReceiptUpdateRequest req=%+v res=%+v", js(req), js(res))
return err
}
func (t *RoomserverInternalAPITrace) QueryRoomReceipts(ctx context.Context, req *QueryRoomReceiptRequest, res *QueryRoomReceiptResponse) error {
err := t.Impl.QueryRoomReceipts(ctx, req, res)
util.GetLogger(ctx).WithError(err).Infof("QueryRoomReceiptRequest req=%+v res=%+v", js(req), js(res))
return err
}

View file

@ -22,6 +22,7 @@ import (
"strings"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/gomatrixserverlib"
)
@ -401,3 +402,12 @@ func (r *QueryCurrentStateResponse) UnmarshalJSON(data []byte) error {
}
return nil
}
type QueryRoomReceiptRequest struct {
RoomID string `json:"room_id"`
TS int `json:"ts"`
}
type QueryRoomReceiptResponse struct {
Receipts []types.Receipt `json:"receipts"`
}

View file

@ -1,10 +1,22 @@
package api
type PerformUserReceiptUpdateRequest struct {
RoomID string
ReceiptType string
EventID string
UserID string
RoomID string `json:"room_id"`
ReceiptType string `json:"type"`
EventID string `json:"event_id"`
UserID string `json:"user_id"`
}
type PerformUserReceiptUpdateResponse struct{}
type ReceiptEvent struct {
Content map[string]struct {
Data map[string]TS `json:"m.read"`
} `json:"content"`
RoomID string `json:"room_id"`
Type string `json:"type"`
}
type TS struct {
TimeStamp int `json:"ts"`
}