mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Add QueryRoomReceipts to roomserver
This commit is contained in:
parent
38de251d9f
commit
0815809634
|
|
@ -155,3 +155,11 @@ func (r *RoomserverInternalAPI) PerformUserReceiptUpdate(
|
|||
) error {
|
||||
return r.Receipter.PerformUserReceiptUpdate(ctx, req, res)
|
||||
}
|
||||
|
||||
func (r *RoomserverInternalAPI) QueryRoomReceipts(
|
||||
ctx context.Context,
|
||||
req *api.QueryRoomReceiptRequest,
|
||||
res *api.QueryRoomReceiptResponse,
|
||||
) error {
|
||||
return r.Receipter.QueryRoomReceipts(ctx, req, res)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,3 +14,16 @@ type Receipter struct {
|
|||
func (r *Receipter) PerformUserReceiptUpdate(ctx context.Context, req *api.PerformUserReceiptUpdateRequest, res *api.PerformUserReceiptUpdateResponse) error {
|
||||
return r.DB.StoreReceipt(ctx, req.RoomID, req.ReceiptType, req.UserID, req.EventID)
|
||||
}
|
||||
|
||||
func (r *Receipter) QueryRoomReceipts(
|
||||
ctx context.Context,
|
||||
req *api.QueryRoomReceiptRequest,
|
||||
res *api.QueryRoomReceiptResponse,
|
||||
) error {
|
||||
receipts, err := r.DB.GetRoomReceipts(ctx, req.RoomID, req.TS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.Receipts = receipts
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -685,3 +685,16 @@ func (r *Queryer) QueryServerBannedFromRoom(ctx context.Context, req *api.QueryS
|
|||
res.Banned = r.ServerACLs.IsServerBannedFromRoom(req.ServerName, req.RoomID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Queryer) QueryRoomReceipts(
|
||||
ctx context.Context,
|
||||
req *api.QueryRoomReceiptRequest,
|
||||
res *api.QueryRoomReceiptResponse,
|
||||
) error {
|
||||
receipts, err := r.DB.GetRoomReceipts(ctx, req.RoomID, req.TS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.Receipts = receipts
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ const (
|
|||
RoomserverQuerySharedUsersPath = "/roomserver/querySharedUsers"
|
||||
RoomserverQueryKnownUsersPath = "/roomserver/queryKnownUsers"
|
||||
RoomserverQueryServerBannedFromRoomPath = "/roomserver/queryServerBannedFromRoom"
|
||||
RoomserverQueryRoomReceiptsPath = "/roomserver/queryRoomReceipts"
|
||||
)
|
||||
|
||||
type httpRoomserverInternalAPI struct {
|
||||
|
|
@ -505,3 +506,15 @@ func (h *httpRoomserverInternalAPI) PerformUserReceiptUpdate(
|
|||
apiURL := h.roomserverURL + RoomserverPerformReceiptUpdatePath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
}
|
||||
|
||||
func (h *httpRoomserverInternalAPI) QueryRoomReceipts(
|
||||
ctx context.Context,
|
||||
req *api.QueryRoomReceiptRequest,
|
||||
res *api.QueryRoomReceiptResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "RoomserverQueryRoomReceiptsPath")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.roomserverURL + RoomserverQueryRoomReceiptsPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue