mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 19:33:09 -06:00
Try this again
This commit is contained in:
parent
8123a76117
commit
adc7f36d38
|
|
@ -15,8 +15,6 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -126,10 +124,6 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
|||
|
||||
if !syncData.IsEmpty() || hasTimedOut {
|
||||
logger.WithField("next", syncData.NextBatch).WithField("timed_out", hasTimedOut).Info("Responding")
|
||||
|
||||
j, _ := json.MarshalIndent(syncData, "", " ")
|
||||
fmt.Println(string(j))
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: syncData,
|
||||
|
|
|
|||
|
|
@ -247,20 +247,19 @@ func NewJoinResponse() *JoinResponse {
|
|||
// InviteResponse represents a /sync response for a room which is under the 'invite' key.
|
||||
type InviteResponse struct {
|
||||
InviteState struct {
|
||||
Events json.RawMessage `json:"events,omitempty"`
|
||||
} `json:"invite_state,omitempty"`
|
||||
Events []json.RawMessage `json:"events"`
|
||||
} `json:"invite_state"`
|
||||
}
|
||||
|
||||
// NewInviteResponse creates an empty response with initialised arrays.
|
||||
func NewInviteResponse(ev gomatrixserverlib.HeaderedEvent) *InviteResponse {
|
||||
res := InviteResponse{}
|
||||
res.InviteState.Events = []json.RawMessage{}
|
||||
var unsigned struct {
|
||||
InviteRoomState json.RawMessage `json:"invite_room_state"`
|
||||
InviteRoomState []json.RawMessage `json:"invite_room_state"`
|
||||
}
|
||||
if err := json.Unmarshal(ev.Unsigned(), &unsigned); err == nil {
|
||||
if len(unsigned.InviteRoomState) > 0 {
|
||||
res.InviteState.Events = unsigned.InviteRoomState
|
||||
}
|
||||
res.InviteState.Events = append(res.InviteState.Events, unsigned.InviteRoomState...)
|
||||
}
|
||||
return &res
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue