mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add '/api/v1/auth/preferences'
This commit is contained in:
parent
734905d1f7
commit
8a525bc131
1 changed files with 19 additions and 8 deletions
|
@ -4388,15 +4388,26 @@ get "/api/v1/auth/notifications" do |env|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO
|
get "/api/v1/auth/preferences" do |env|
|
||||||
# get "/api/v1/auth/preferences" do |env|
|
env.response.content_type = "application/json"
|
||||||
# ...
|
user = env.get("user").as(User)
|
||||||
# end
|
user.preferences.to_json
|
||||||
|
end
|
||||||
|
|
||||||
# TODO
|
post "/api/v1/auth/preferences" do |env|
|
||||||
# post "/api/v1/auth/preferences" do |env|
|
env.response.content_type = "application/json"
|
||||||
# ...
|
user = env.get("user").as(User)
|
||||||
# end
|
|
||||||
|
begin
|
||||||
|
preferences = Preferences.from_json(env.request.body || "{}")
|
||||||
|
rescue
|
||||||
|
preferences = user.preferences
|
||||||
|
end
|
||||||
|
|
||||||
|
PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences.to_json, user.email)
|
||||||
|
|
||||||
|
env.response.status_code = 204
|
||||||
|
end
|
||||||
|
|
||||||
get "/api/v1/auth/subscriptions" do |env|
|
get "/api/v1/auth/subscriptions" do |env|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
|
|
Loading…
Reference in a new issue