mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Notify clients when devices are deleted (#1233)
* Recheck device lists when join/leave events come in * Add PerformDeviceDeletion * Notify clients when devices are deleted * Unbreak things * Remove debug logging
This commit is contained in:
parent
292a9ddd82
commit
a7e67e65a8
25 changed files with 183 additions and 47 deletions
|
@ -30,6 +30,7 @@ const (
|
|||
|
||||
PerformDeviceCreationPath = "/userapi/performDeviceCreation"
|
||||
PerformAccountCreationPath = "/userapi/performAccountCreation"
|
||||
PerformDeviceDeletionPath = "/userapi/performDeviceDeletion"
|
||||
|
||||
QueryProfilePath = "/userapi/queryProfile"
|
||||
QueryAccessTokenPath = "/userapi/queryAccessToken"
|
||||
|
@ -91,6 +92,18 @@ func (h *httpUserInternalAPI) PerformDeviceCreation(
|
|||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
func (h *httpUserInternalAPI) PerformDeviceDeletion(
|
||||
ctx context.Context,
|
||||
request *api.PerformDeviceDeletionRequest,
|
||||
response *api.PerformDeviceDeletionResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformDeviceDeletion")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.apiURL + PerformDeviceDeletionPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
func (h *httpUserInternalAPI) QueryProfile(
|
||||
ctx context.Context,
|
||||
request *api.QueryProfileRequest,
|
||||
|
|
|
@ -52,6 +52,19 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(PerformDeviceDeletionPath,
|
||||
httputil.MakeInternalAPI("performDeviceDeletion", func(req *http.Request) util.JSONResponse {
|
||||
request := api.PerformDeviceDeletionRequest{}
|
||||
response := api.PerformDeviceDeletionResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := s.PerformDeviceDeletion(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(QueryProfilePath,
|
||||
httputil.MakeInternalAPI("queryProfile", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryProfileRequest{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue