0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🐛 Fix internal error on ws connect on notification with not existing file.

This commit is contained in:
Andrey Antukh 2020-06-10 09:09:54 +02:00
parent 7fb897a7ad
commit bab73cf4eb
2 changed files with 19 additions and 4 deletions

View file

@ -17,21 +17,33 @@
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
[ring.middleware.params :refer [wrap-params]]
[uxbox.common.spec :as us]
[uxbox.db :as db]
[uxbox.http.session :refer [wrap-auth]]
[uxbox.services.notifications :as nf]))
(s/def ::file-id ::us/uuid)
(s/def ::session-id ::us/uuid)
(s/def ::websocket-params
(s/keys :req-un [::file-id ::session-id]))
(defn websocket
[{:keys [profile-id] :as req}]
(let [params (us/conform ::websocket-params (:params req))
params (assoc params :profile-id profile-id)]
(if profile-id
(nf/websocket params)
{:error {:code 403 :message "Authentication required"}})))
file (db/get-by-id db/pool :file (:file-id params))
params (assoc params
:profile-id profile-id
:file file)]
(cond
(not profile-id)
{:error {:code 403 :message "Authentication required"}}
(not file)
{:error {:code 404 :message "File does not exists"}}
:else
(nf/websocket params))))
(def handler
(-> websocket

View file

@ -2,6 +2,9 @@
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL
(ns uxbox.services.notifications