diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-11-08 16:35:26 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-11-08 16:35:26 -0600 |
| commit | 0a1c84ada18b9e8bdbfaf27abdc06b48bdd1fda9 (patch) | |
| tree | 329b3ecf2c73f023bc6558c6c948e6a94014f7d7 | |
| parent | fee3b93339e9d6cc2d268a5b5c34cefab795c593 (diff) | |
| download | invidious-0a1c84ada18b9e8bdbfaf27abdc06b48bdd1fda9.tar.gz invidious-0a1c84ada18b9e8bdbfaf27abdc06b48bdd1fda9.tar.bz2 invidious-0a1c84ada18b9e8bdbfaf27abdc06b48bdd1fda9.zip | |
Add support for partial data restore
| -rw-r--r-- | src/invidious.cr | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 199ad602..3602ed70 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1212,7 +1212,7 @@ post "/data_control" do |env| case part.name when "import_invidious" body = JSON.parse(body) - body["subscriptions"].as_a.each do |ucid| + body["subscriptions"]?.try &.as_a.each do |ucid| ucid = ucid.as_s if !user.subscriptions.includes? ucid @@ -1228,7 +1228,7 @@ post "/data_control" do |env| end end - body["watch_history"].as_a.each do |id| + body["watch_history"]?.try &.as_a.each do |id| id = id.as_s if !user.watched.includes? id @@ -1237,7 +1237,9 @@ post "/data_control" do |env| end end + if body["preferences"]? PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", body["preferences"].to_json, user.email) + end when "import_youtube" subscriptions = XML.parse(body) subscriptions.xpath_nodes(%q(//outline[@type="rss"])).each do |channel| |
