diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8b6f4db02..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: 2 -jobs: - dendrite: - docker: - - image: matrixdotorg/sytest-dendrite - working_directory: /src - steps: - - checkout - - # Set up dendrite - - run: - name: Build Dendrite - command: ./build.sh - - run: - name: Copy dummy keys to root - command: | - mv .circleci/matrix_key.pem . - mv .circleci/server.key . - - run: - name: Run sytest with whitelisted tests - command: /dendrite_sytest.sh - - - store_artifacts: - path: /logs - destination: logs - - store_test_results: - path: /logs -workflows: - version: 2 - build: - jobs: - - dendrite diff --git a/.circleci/matrix_key.pem b/.circleci/matrix_key.pem deleted file mode 100644 index 6691c74af..000000000 --- a/.circleci/matrix_key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN MATRIX PRIVATE KEY----- -Key-ID: ed25519:zXtB - -jDyHsx0EXbAfvM32yBEKQfIy1FHrmwtB1uMAbm5INBg= ------END MATRIX PRIVATE KEY----- diff --git a/.circleci/server.key b/.circleci/server.key deleted file mode 100644 index a5c485079..000000000 --- a/.circleci/server.key +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCanRCqP11MLIQh -nC26+A1oyBsFfH7auZ3pqE/WFDrCCIoc7ek7cF3fZU7q8OYI+Q9L5V8fobuLb6FB -iXD5zZ6pBAI0VNjAS8yi8VluXIv6pJKsVY3k2hGiU7xRoEhkzckZBaEiruspQbcX -ziNoWoueVBB1a4Eproqzy225cTcoprHsJIPXj0HpW/jKcmahmlM/OrqRAxTwxpb/ -moI6MWIeN4n7h55N6dU1ScVvBS7gZpZQ28d8akuvG3m8kE8q1OPFYGvrNeowD4sp -qDPFijhbygwpzDQlAWriPcqV9KhuGRnYRGTGvuluOttmpgNhNFVxVAlwZJuMVAMU -Jhek66ntKsxWkF5LsO8ls20hmHyyAsL7+rb2Z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HW419YnuhveBFX+25 -kN8MHHXk5aNcxE+akLWYJimHCVGueScdUIC5OEtDHS8guQx48PUPCOPNeyn8XNzw -ZmG9Xqy0dWK+AK6mXOcUKvbhjWSbEmySo5NVj0JHkdsfmr9A4Fbntcr4yuCBlYve -TYIMccark3hZci3HzgzWmbSlFv3f/Cd787A19VWRE8nK+9k1oIDBmhIM8M8s/c9m -kbOApLkm7O8Tb7dYWQgFZbgNdOEuU5bhAk4fuHuDYBPWmPVMQdkvOnvuWlM61ubF -LdaBAoIBACDpbb5AQIYsWWOnoXuuGh+YY4kmnaBFpsbgEYkZSy92AaLr4Ibf49WN -oqNDX73YaJlURaGPYMC9J2Huq7TZcewH3SwkVA3N5UmDoijkM4juRfADAfVIMxB5 -+9paWeEfnYC/o377FTJIJ9hHJWIaWSoiJZLYDBmoYdxmk8DSHAJCeWsjYDzPybsH -7RyMPIa1u7lVdgOPEOBi1OIg7ASLxGKiHQtrYHq99GcaVvU/UxoNRMcSnPfY3G8R -pGah+EndSCb2F20ouDyvlKfOylAltH2BeNc3B4PeP7ZhlVr7bfyOAfC2Z7FNDm3J -+yaBExKfroZjsksctNAcAbgpuvhLLG8= ------END PRIVATE KEY----- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc962fee7..fa815f15b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,9 @@ run](scripts/build-test-lint.sh). When a Pull Request is submitted, continuous integration jobs are run automatically to ensure the code builds and is relatively well-written. Checks are run on [Buildkite](https://buildkite.com/matrix-dot-org/dendrite/) and -[CircleCI](https://circleci.com/gh/matrix-org/dendrite/). +[CircleCI](https://circleci.com/gh/matrix-org/dendrite/). The Buildkite +pipeline can be found in Matrix.org's [pipelines +repository](https://github.com/matrix-org/pipelines). If a job fails, click the "details" button and you should be taken to the job's logs. diff --git a/clientapi/auth/storage/accounts/account_data_table.go b/clientapi/auth/storage/accounts/account_data_table.go index 0d73cb312..0d6ad0933 100644 --- a/clientapi/auth/storage/accounts/account_data_table.go +++ b/clientapi/auth/storage/accounts/account_data_table.go @@ -120,28 +120,17 @@ func (s *accountDataStatements) selectAccountData( func (s *accountDataStatements) selectAccountDataByType( ctx context.Context, localpart, roomID, dataType string, -) (data []gomatrixserverlib.ClientEvent, err error) { - data = []gomatrixserverlib.ClientEvent{} - +) (data *gomatrixserverlib.ClientEvent, err error) { stmt := s.selectAccountDataByTypeStmt - rows, err := stmt.QueryContext(ctx, localpart, roomID, dataType) - if err != nil { + var content []byte + + if err = stmt.QueryRowContext(ctx, localpart, roomID, dataType).Scan(&content); err != nil { return } - for rows.Next() { - var content []byte - - if err = rows.Scan(&content); err != nil { - return - } - - ac := gomatrixserverlib.ClientEvent{ - Type: dataType, - Content: content, - } - - data = append(data, ac) + data = &gomatrixserverlib.ClientEvent{ + Type: dataType, + Content: content, } return diff --git a/clientapi/auth/storage/accounts/storage.go b/clientapi/auth/storage/accounts/storage.go index 41d75daad..020a38376 100644 --- a/clientapi/auth/storage/accounts/storage.go +++ b/clientapi/auth/storage/accounts/storage.go @@ -263,11 +263,11 @@ func (d *Database) GetAccountData(ctx context.Context, localpart string) ( // GetAccountDataByType returns account data matching a given // localpart, room ID and type. -// If no account data could be found, returns an empty array +// If no account data could be found, returns nil // Returns an error if there was an issue with the retrieval func (d *Database) GetAccountDataByType( ctx context.Context, localpart, roomID, dataType string, -) (data []gomatrixserverlib.ClientEvent, err error) { +) (data *gomatrixserverlib.ClientEvent, err error) { return d.accountDatas.selectAccountDataByType( ctx, localpart, roomID, dataType, ) diff --git a/clientapi/routing/room_tagging.go b/clientapi/routing/room_tagging.go index 6e7324cd8..487081c53 100644 --- a/clientapi/routing/room_tagging.go +++ b/clientapi/routing/room_tagging.go @@ -59,7 +59,7 @@ func GetTags( return httputil.LogThenError(req, err) } - if len(data) == 0 { + if data == nil { return util.JSONResponse{ Code: http.StatusOK, JSON: struct{}{}, @@ -68,7 +68,7 @@ func GetTags( return util.JSONResponse{ Code: http.StatusOK, - JSON: data[0].Content, + JSON: data.Content, } } @@ -103,8 +103,8 @@ func PutTag( } var tagContent gomatrix.TagContent - if len(data) > 0 { - if err = json.Unmarshal(data[0].Content, &tagContent); err != nil { + if data != nil { + if err = json.Unmarshal(data.Content, &tagContent); err != nil { return httputil.LogThenError(req, err) } } else { @@ -155,7 +155,7 @@ func DeleteTag( } // If there are no tags in the database, exit - if len(data) == 0 { + if data == nil { // Spec only defines 200 responses for this endpoint so we don't return anything else. return util.JSONResponse{ Code: http.StatusOK, @@ -164,7 +164,7 @@ func DeleteTag( } var tagContent gomatrix.TagContent - err = json.Unmarshal(data[0].Content, &tagContent) + err = json.Unmarshal(data.Content, &tagContent) if err != nil { return httputil.LogThenError(req, err) } @@ -204,7 +204,7 @@ func obtainSavedTags( userID string, roomID string, accountDB *accounts.Database, -) (string, []gomatrixserverlib.ClientEvent, error) { +) (string, *gomatrixserverlib.ClientEvent, error) { localpart, _, err := gomatrixserverlib.SplitID('@', userID) if err != nil { return "", nil, err diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 6b95f4698..94a369001 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -196,13 +196,13 @@ func (rp *RequestPool) appendAccountData( events := []gomatrixserverlib.ClientEvent{} // Request the missing data from the database for _, dataType := range dataTypes { - evs, err := rp.accountDB.GetAccountDataByType( + event, err := rp.accountDB.GetAccountDataByType( req.ctx, localpart, roomID, dataType, ) if err != nil { return nil, err } - events = append(events, evs...) + events = append(events, *event) } // Append the data to the response diff --git a/testfile b/testfile index 963c1f7ce..5ad3426e9 100644 --- a/testfile +++ b/testfile @@ -171,6 +171,7 @@ Outbound federation can query profile data /event/ on joined room works /event/ does not allow access to events before the user joined Federation key API allows unsigned requests for keys +Can paginate public room list GET /directory/room/:room_alias yields room ID PUT /directory/room/:room_alias creates alias Room aliases can contain Unicode