From 25504f20f32130a7c9047da6700a146f27bbd599 Mon Sep 17 00:00:00 2001 From: Derek Meer Date: Wed, 1 Aug 2018 19:22:45 -0700 Subject: [PATCH] Initial structuring for URIToUID API --- .../dendrite/appservice/routing/routing.go | 6 +---- .../dendrite/appservice/routing/user.go | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 src/github.com/matrix-org/dendrite/appservice/routing/user.go diff --git a/src/github.com/matrix-org/dendrite/appservice/routing/routing.go b/src/github.com/matrix-org/dendrite/appservice/routing/routing.go index f0b8461dc..0a379cbf2 100644 --- a/src/github.com/matrix-org/dendrite/appservice/routing/routing.go +++ b/src/github.com/matrix-org/dendrite/appservice/routing/routing.go @@ -51,11 +51,7 @@ func Setup( ).Methods(http.MethodGet, http.MethodOptions) appMux.Handle("/user", common.MakeExternalAPI("user", func(req *http.Request) util.JSONResponse { - // TODO: Implement - return util.JSONResponse{ - Code: http.StatusOK, - JSON: nil, - } + return URIToUID(req) }), ).Methods(http.MethodGet, http.MethodOptions) } diff --git a/src/github.com/matrix-org/dendrite/appservice/routing/user.go b/src/github.com/matrix-org/dendrite/appservice/routing/user.go new file mode 100644 index 000000000..2c167dc55 --- /dev/null +++ b/src/github.com/matrix-org/dendrite/appservice/routing/user.go @@ -0,0 +1,25 @@ +package routing + +import ( + "github.com/matrix-org/util" + "net/http" +) + +// represents response to an AppService URI to User Id +// (/_matrix/app/r0/user?uri={url_encoded_uri}) request +type URIToUIDResponse struct { + UserID string `json:"user_id"` +} + +// URIToUID implements `/_matrix/app/r0/user?uri={url_encoded_uri}`, which +// enables users to contact appservice users directly by taking an encoded +// URI and turning it into a Matrix ID on the homeserver. +// https://matrix.org/docs/spec/application_service/unstable.html#user-ids + +func URIToUID(req *http.Request) util.JSONResponse { + // TODO: Implement + return util.JSONResponse{ + Code: http.StatusOK, + JSON: nil, + } +}