mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 03:13:11 -06:00
Weird error commit
This commit is contained in:
commit
97e7729021
|
|
@ -35,10 +35,10 @@ cd dendrite
|
||||||
|
|
||||||
If using Kafka, install and start it (c.f. [scripts/install-local-kafka.sh](scripts/install-local-kafka.sh)):
|
If using Kafka, install and start it (c.f. [scripts/install-local-kafka.sh](scripts/install-local-kafka.sh)):
|
||||||
```bash
|
```bash
|
||||||
MIRROR=http://apache.mirror.anlx.net/kafka/0.10.2.0/kafka_2.11-0.10.2.0.tgz
|
KAFKA_URL=http://archive.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
|
||||||
|
|
||||||
# Only download the kafka if it isn't already downloaded.
|
# Only download the kafka if it isn't already downloaded.
|
||||||
test -f kafka.tgz || wget $MIRROR -O kafka.tgz
|
test -f kafka.tgz || wget $KAFKA_URL -O kafka.tgz
|
||||||
# Unpack the kafka over the top of any existing installation
|
# Unpack the kafka over the top of any existing installation
|
||||||
mkdir -p kafka && tar xzf kafka.tgz -C kafka --strip-components 1
|
mkdir -p kafka && tar xzf kafka.tgz -C kafka --strip-components 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,6 @@ func SaveAccountData(
|
||||||
req *http.Request, accountDB *accounts.Database, device *authtypes.Device,
|
req *http.Request, accountDB *accounts.Database, device *authtypes.Device,
|
||||||
userID string, roomID string, dataType string, syncProducer *producers.SyncAPIProducer,
|
userID string, roomID string, dataType string, syncProducer *producers.SyncAPIProducer,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodPut {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if userID != device.UserID {
|
if userID != device.UserID {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,6 @@ func UpdateDeviceByID(
|
||||||
req *http.Request, deviceDB *devices.Database, device *authtypes.Device,
|
req *http.Request, deviceDB *devices.Database, device *authtypes.Device,
|
||||||
deviceID string,
|
deviceID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodPut {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad Method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
|
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,6 @@ import (
|
||||||
func GetFilter(
|
func GetFilter(
|
||||||
req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string, filterID string,
|
req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string, filterID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodGet {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if userID != device.UserID {
|
if userID != device.UserID {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
|
|
@ -79,12 +73,6 @@ type filterResponse struct {
|
||||||
func PutFilter(
|
func PutFilter(
|
||||||
req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string,
|
req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodPost {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if userID != device.UserID {
|
if userID != device.UserID {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
||||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
@ -29,13 +28,6 @@ import (
|
||||||
func Logout(
|
func Logout(
|
||||||
req *http.Request, deviceDB *devices.Database, device *authtypes.Device,
|
req *http.Request, deviceDB *devices.Database, device *authtypes.Device,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodPost {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
|
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,6 @@ import (
|
||||||
func GetProfile(
|
func GetProfile(
|
||||||
req *http.Request, accountDB *accounts.Database, userID string, asAPI appserviceAPI.AppServiceQueryAPI,
|
req *http.Request, accountDB *accounts.Database, userID string, asAPI appserviceAPI.AppServiceQueryAPI,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if req.Method != http.MethodGet {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.NotFound("Bad method"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
profile, err := appserviceAPI.RetrieveUserProfile(req.Context(), userID, asAPI, accountDB)
|
profile, err := appserviceAPI.RetrieveUserProfile(req.Context(), userID, asAPI, accountDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,12 @@ func (d sessionsDict) GetCompletedStages(sessionID string) []authtypes.LoginType
|
||||||
|
|
||||||
// AddCompletedStage records that a session has completed an auth stage.
|
// AddCompletedStage records that a session has completed an auth stage.
|
||||||
func (d *sessionsDict) AddCompletedStage(sessionID string, stage authtypes.LoginType) {
|
func (d *sessionsDict) AddCompletedStage(sessionID string, stage authtypes.LoginType) {
|
||||||
|
// Return if the stage is already present
|
||||||
|
for _, completedStage := range d.GetCompletedStages(sessionID) {
|
||||||
|
if completedStage == stage {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
d.sessions[sessionID] = append(d.GetCompletedStages(sessionID), stage)
|
d.sessions[sessionID] = append(d.GetCompletedStages(sessionID), stage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,13 @@ import (
|
||||||
"github.com/matrix-org/gomatrix"
|
"github.com/matrix-org/gomatrix"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// newTag creates and returns a new Tag type
|
// newTag creates and returns a new Tag type
|
||||||
func newTag() gomatrix.TagContent {
|
func newTag() gomatrix.TagContent {
|
||||||
return gomatrix.TagContent{
|
return gomatrix.TagContent{
|
||||||
Tags: make(map[string]gomatrix.TagProperties),
|
Map: make(map[string]gomatrix.TagProperties),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,8 +70,13 @@ func GetTags(
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Info("MYDUMBDATA")
|
||||||
|
var tagData []gomatrix.TagData
|
||||||
tagContent := newTag()
|
tagContent := newTag()
|
||||||
err = json.Unmarshal(dataByte, &tagContent)
|
err = json.Unmarshal(dataByte, &tagData)
|
||||||
|
tagData[0].Content.Map["something"] = gomatrix.TagProperties{0}
|
||||||
|
logrus.Info(tagData[0].Content.Map)
|
||||||
|
tagContent = tagData[0].Content
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
|
|
@ -83,7 +89,7 @@ func GetTags(
|
||||||
|
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
JSON: tagContent,
|
JSON: tagContent.Map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +134,7 @@ func PutTag(
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tagContent.Tags[tag] = properties
|
tagContent.Map[tag] = properties
|
||||||
err = saveTagData(req, localpart, roomID, accountDB, tagContent)
|
err = saveTagData(req, localpart, roomID, accountDB, tagContent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
|
|
@ -188,8 +194,8 @@ func DeleteTag(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the Tag to be deleted exists
|
// Check whether the Tag to be deleted exists
|
||||||
if _, ok := tagContent.Tags[tag]; ok {
|
if _, ok := tagContent.Map[tag]; ok {
|
||||||
delete(tagContent.Tags, tag)
|
delete(tagContent.Map, tag)
|
||||||
} else {
|
} else {
|
||||||
//Synapse returns a 200 OK response on finding no Tags, same policy is followed here.
|
//Synapse returns a 200 OK response on finding no Tags, same policy is followed here.
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func Setup(
|
||||||
v2keysmux.Handle("/server/{keyID}", localKeys).Methods(http.MethodGet)
|
v2keysmux.Handle("/server/{keyID}", localKeys).Methods(http.MethodGet)
|
||||||
v2keysmux.Handle("/server/", localKeys).Methods(http.MethodGet)
|
v2keysmux.Handle("/server/", localKeys).Methods(http.MethodGet)
|
||||||
|
|
||||||
v1fedmux.Handle("/send/{txnID}/", common.MakeFedAPI(
|
v1fedmux.Handle("/send/{txnID}", common.MakeFedAPI(
|
||||||
"federation_send", cfg.Matrix.ServerName, keys,
|
"federation_send", cfg.Matrix.ServerName, keys,
|
||||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||||
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
||||||
|
|
@ -260,7 +260,7 @@ func Setup(
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodPost)
|
)).Methods(http.MethodPost)
|
||||||
|
|
||||||
v1fedmux.Handle("/backfill/{roomID}/", common.MakeFedAPI(
|
v1fedmux.Handle("/backfill/{roomID}", common.MakeFedAPI(
|
||||||
"federation_backfill", cfg.Matrix.ServerName, keys,
|
"federation_backfill", cfg.Matrix.ServerName, keys,
|
||||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
||||||
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ type downloadRequest struct {
|
||||||
Logger *log.Entry
|
Logger *log.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download implements /download amd /thumbnail
|
// Download implements GET /download and GET /thumbnail
|
||||||
// Files from this server (i.e. origin == cfg.ServerName) are served directly
|
// Files from this server (i.e. origin == cfg.ServerName) are served directly
|
||||||
// Files from remote servers (i.e. origin != cfg.ServerName) are cached locally.
|
// Files from remote servers (i.e. origin != cfg.ServerName) are cached locally.
|
||||||
// If they are present in the cache, they are served directly.
|
// If they are present in the cache, they are served directly.
|
||||||
|
|
@ -107,14 +107,6 @@ func Download(
|
||||||
}
|
}
|
||||||
|
|
||||||
// request validation
|
// request validation
|
||||||
if req.Method != http.MethodGet {
|
|
||||||
dReq.jsonErrorResponse(w, util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.Unknown("request method must be GET"),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if resErr := dReq.Validate(); resErr != nil {
|
if resErr := dReq.Validate(); resErr != nil {
|
||||||
dReq.jsonErrorResponse(w, *resErr)
|
dReq.jsonErrorResponse(w, *resErr)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ type uploadResponse struct {
|
||||||
ContentURI string `json:"content_uri"`
|
ContentURI string `json:"content_uri"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload implements /upload
|
// Upload implements POST /upload
|
||||||
// This endpoint involves uploading potentially significant amounts of data to the homeserver.
|
// This endpoint involves uploading potentially significant amounts of data to the homeserver.
|
||||||
// This implementation supports a configurable maximum file size limit in bytes. If a user tries to upload more than this, they will receive an error that their upload is too large.
|
// This implementation supports a configurable maximum file size limit in bytes. If a user tries to upload more than this, they will receive an error that their upload is too large.
|
||||||
// Uploaded files are processed piece-wise to avoid DoS attacks which would starve the server of memory.
|
// Uploaded files are processed piece-wise to avoid DoS attacks which would starve the server of memory.
|
||||||
|
|
@ -75,13 +75,6 @@ func Upload(req *http.Request, cfg *config.Dendrite, db *storage.Database, activ
|
||||||
// all the metadata about the media being uploaded.
|
// all the metadata about the media being uploaded.
|
||||||
// Returns either an uploadRequest or an error formatted as a util.JSONResponse
|
// Returns either an uploadRequest or an error formatted as a util.JSONResponse
|
||||||
func parseAndValidateRequest(req *http.Request, cfg *config.Dendrite) (*uploadRequest, *util.JSONResponse) {
|
func parseAndValidateRequest(req *http.Request, cfg *config.Dendrite) (*uploadRequest, *util.JSONResponse) {
|
||||||
if req.Method != http.MethodPost {
|
|
||||||
return nil, &util.JSONResponse{
|
|
||||||
Code: http.StatusMethodNotAllowed,
|
|
||||||
JSON: jsonerror.Unknown("HTTP request method must be POST."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r := &uploadRequest{
|
r := &uploadRequest{
|
||||||
MediaMetadata: &types.MediaMetadata{
|
MediaMetadata: &types.MediaMetadata{
|
||||||
Origin: cfg.Matrix.ServerName,
|
Origin: cfg.Matrix.ServerName,
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ type publicRoomRes struct {
|
||||||
Estimate int64 `json:"total_room_count_estimate,omitempty"`
|
Estimate int64 `json:"total_room_count_estimate,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPublicRooms implements GET /publicRooms
|
// GetPostPublicRooms implements GET and POST /publicRooms
|
||||||
func GetPublicRooms(
|
func GetPostPublicRooms(
|
||||||
req *http.Request, publicRoomDatabase *storage.PublicRoomsServerDatabase,
|
req *http.Request, publicRoomDatabase *storage.PublicRoomsServerDatabase,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
var limit int16
|
var limit int16
|
||||||
|
|
@ -89,6 +89,7 @@ func GetPublicRooms(
|
||||||
|
|
||||||
// fillPublicRoomsReq fills the Limit, Since and Filter attributes of a GET or POST request
|
// fillPublicRoomsReq fills the Limit, Since and Filter attributes of a GET or POST request
|
||||||
// on /publicRooms by parsing the incoming HTTP request
|
// on /publicRooms by parsing the incoming HTTP request
|
||||||
|
// Filter is only filled for POST requests
|
||||||
func fillPublicRoomsReq(httpReq *http.Request, request *publicRoomReq) *util.JSONResponse {
|
func fillPublicRoomsReq(httpReq *http.Request, request *publicRoomReq) *util.JSONResponse {
|
||||||
if httpReq.Method == http.MethodGet {
|
if httpReq.Method == http.MethodGet {
|
||||||
limit, err := strconv.Atoi(httpReq.FormValue("limit"))
|
limit, err := strconv.Atoi(httpReq.FormValue("limit"))
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func Setup(apiMux *mux.Router, deviceDB *devices.Database, publicRoomsDB *storag
|
||||||
).Methods(http.MethodPut, http.MethodOptions)
|
).Methods(http.MethodPut, http.MethodOptions)
|
||||||
r0mux.Handle("/publicRooms",
|
r0mux.Handle("/publicRooms",
|
||||||
common.MakeExternalAPI("public_rooms", func(req *http.Request) util.JSONResponse {
|
common.MakeExternalAPI("public_rooms", func(req *http.Request) util.JSONResponse {
|
||||||
return directory.GetPublicRooms(req, publicRoomsDB)
|
return directory.GetPostPublicRooms(req, publicRoomsDB)
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
testfile
4
testfile
|
|
@ -148,4 +148,6 @@ Typing events appear in initial sync
|
||||||
Typing events appear in incremental sync
|
Typing events appear in incremental sync
|
||||||
Typing events appear in gapped sync
|
Typing events appear in gapped sync
|
||||||
Can add tag
|
Can add tag
|
||||||
Can remove tag
|
Can remove tag
|
||||||
|
Inbound federation of state requires event_id as a mandatory paramater
|
||||||
|
Inbound federation of state_ids requires event_id as a mandatory paramater
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue