mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 14:33:10 -06:00
remove the config check for thread list because why not
This commit is contained in:
parent
15aaac5983
commit
ad721d93b0
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -150,49 +149,47 @@ func Enable(
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodPost, http.MethodOptions)
|
)).Methods(http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
if slices.Contains(cfg.MSCs.MSCs, "MSC3856") {
|
routers.Client.Handle("/v1/rooms/{roomId}/threads", httputil.MakeAuthAPI(
|
||||||
routers.Client.Handle("/v1/rooms/{roomId}/threads", httputil.MakeAuthAPI(
|
"msc3856_thread_list", userAPI, func(req *http.Request, d *userapi.Device) util.JSONResponse {
|
||||||
"msc3856_thread_list", userAPI, func(req *http.Request, d *userapi.Device) util.JSONResponse {
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
if err != nil {
|
||||||
if err != nil {
|
return util.ErrorResponse(err)
|
||||||
return util.ErrorResponse(err)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
roomID := vars["roomID"]
|
roomID := vars["roomID"]
|
||||||
limit, err := strconv.ParseUint(req.URL.Query().Get("limit"), 10, 64)
|
limit, err := strconv.ParseUint(req.URL.Query().Get("limit"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
limit = 50
|
limit = 50
|
||||||
}
|
}
|
||||||
offset, err := strconv.ParseUint(req.URL.Query().Get("from"), 10, 64)
|
offset, err := strconv.ParseUint(req.URL.Query().Get("from"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
childrens, err := db.GetChildrensByRoomId(req.Context(), roomID, true, limit, offset)
|
childrens, err := db.GetChildrensByRoomId(req.Context(), roomID, true, limit, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
chunks := make([]map[string]any, 0)
|
chunks := make([]map[string]any, 0)
|
||||||
for _, child := range childrens {
|
for _, child := range childrens {
|
||||||
chunks = append(chunks,
|
chunks = append(chunks,
|
||||||
map[string]any{
|
map[string]any{
|
||||||
"event_id": child.EventID,
|
"event_id": child.EventID,
|
||||||
"origin_server_ts": child.OriginServerTS,
|
"origin_server_ts": child.OriginServerTS,
|
||||||
"room_id": child.RoomID,
|
"room_id": child.RoomID,
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: 200,
|
|
||||||
JSON: map[string]any{
|
|
||||||
"chunk": chunks,
|
|
||||||
"next_batch": strconv.FormatUint(uint64(len(chunks))+offset, 10),
|
|
||||||
},
|
},
|
||||||
}
|
)
|
||||||
},
|
}
|
||||||
))
|
|
||||||
}
|
return util.JSONResponse{
|
||||||
|
Code: 200,
|
||||||
|
JSON: map[string]any{
|
||||||
|
"chunk": chunks,
|
||||||
|
"next_batch": strconv.FormatUint(uint64(len(chunks))+offset, 10),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue