diff --git a/encryptoapi/routing/keys.go b/encryptoapi/routing/keys.go index 66439316c..7685891ce 100644 --- a/encryptoapi/routing/keys.go +++ b/encryptoapi/routing/keys.go @@ -18,6 +18,10 @@ import ( "context" "encoding/json" "fmt" + "net/http" + "strings" + "time" + "github.com/Shopify/sarama" "github.com/matrix-org/dendrite/clientapi/auth/storage/devices" "github.com/matrix-org/dendrite/clientapi/httputil" @@ -27,9 +31,6 @@ import ( "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/pkg/errors" - "net/http" - "strings" - "time" ) const ( @@ -259,6 +260,17 @@ func ClaimOneTimeKeys( } } +// ChangesInKeys returns the changes in the keys after last sync +func ChangesInKeys(req *http.Request, + encryptionDB *storage.Database, +) util.JSONResponse { + + return util.JSONResponse{ + Code: http.StatusOK, + JSON: struct{}{}, + } +} + // todo: check through interface for duplicate and what type of request should it be // whether device or one time or both of them func checkUpload(req *types.UploadEncryptSpecific, typ int) bool { diff --git a/encryptoapi/routing/routing.go b/encryptoapi/routing/routing.go index eeb6d4ba0..cf1c0eb2e 100644 --- a/encryptoapi/routing/routing.go +++ b/encryptoapi/routing/routing.go @@ -52,7 +52,6 @@ func Setup( unstablemux.Handle("/keys/query", common.MakeAuthAPI("query keys", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse { - //vars := mux.Vars(req) return QueryPKeys(req, encryptionDB, device.ID, deviceDB) }), ).Methods(http.MethodPost, http.MethodOptions) @@ -63,4 +62,10 @@ func Setup( }), ).Methods(http.MethodPost, http.MethodOptions) + unstablemux.Handle("/keys/changes", + common.MakeAuthAPI("get changes", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse { + return ChangesInKeys(req, encryptionDB) + }), + ).Methods(http.MethodGet, http.MethodOptions) + } diff --git a/encryptoapi/types/changes.go b/encryptoapi/types/changes.go new file mode 100644 index 000000000..56d089724 --- /dev/null +++ b/encryptoapi/types/changes.go @@ -0,0 +1,27 @@ +// Copyright Sumukha PK +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +// ChangesRequest structure +type ChangesRequest struct { + From string `json:"from"` + To string `json:"to"` +} + +// ChangesResponse structure +type ChangesResponse struct { + Changed []string `json:"changed"` + Left []string `json:"left"` +} diff --git a/encryptoapi/types/upload.go b/encryptoapi/types/upload.go index 7e8a62c13..d30f0719f 100644 --- a/encryptoapi/types/upload.go +++ b/encryptoapi/types/upload.go @@ -46,12 +46,12 @@ type KeyObject struct { Signature map[string]map[string]string `json:"signatures"` } -// OneTimeKey structure -type OneTimeKey struct { - //KeyString map[string]string - //KeyObject map[string]KeyObject - KeySth map[string]interface{} -} +// // OneTimeKey structure +// type OneTimeKey struct { +// //KeyString map[string]string +// //KeyObject map[string]KeyObject +// KeySth map[string]interface{} +// } // OneTimeKeySpecific structure type OneTimeKeySpecific struct {